Skip to content

Updating react-scripts 4 -> 5, dynamic svg loading not working #721

Discussion options

You must be logged in to vote

Solution: https://ryanhutzley.medium.com/dynamic-svg-imports-in-create-react-app-d6d411f6d6c6

  1. change import to
const SvgComponent = (await import(`assets/icons/${name}.svg`)).ReactComponent;
  1. add @svgr/webpack loader、file-loader

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@dima-getselectstar
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by gregberge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #708 on May 16, 2022 21:10.