After hearing many amazing things about vite I decided to try it and create something and I am not at all disappointed with the DX. So when I was d...
For further actions, you may consider blocking this person and/or reporting abuse
Amazing!
I really appreciate you :)
I have a question why this solution does not work when we use
useStateinstead ofuseRef?Sorry for late comment.
A small note for anyone who tries useState instead of useRef: React treats a function passed to a setter as an updater, so setSvgIcon(ReactComponent) will call the component instead of storing it. Wrap it in an arrow function to fix it:
useRef skips this because assigning to ref.current is a plain assignment.
Also, if you’re on vite-plugin-svgr v4+, import with ?react and use the default export instead of ReactComponent.
The author isn't going to answer questions because he doesn't know. He just stole the code from: StackOverflow without crediting the author. Shameful.
great article!
Thanks for sharing, great article.
Thank you @mondal10, so helpful, you really rescued me in despair.
Thanks @mondal10. Very helpful!
Lmao @jradams1997 pwned
Did I say anywhere in my comment that it was my code? Also, I know it’s probably too hard for you, but you can press the ‘Reply’ button to directly reply. Have a nice day.
Toxic mate
How it influence bundle size ?
It’s a mixed bag, but mostly good.
Pros:
Cons:
Tip: for icons shown on every page (logo, nav), import them statically so they ship in the main bundle and don’t flash a loader. Keep the dynamic folder limited to icons that really are on-demand.