dynamic import heroicons react components
See original GitHub issueIs there any way to make dynamic imports / usage of those react heroicon components?
Normal way:
import {ChevronDownIcon} from "@heroicons/react/solid";
…
JSX:
<ChevronDownIcon/>
Desired:
import {${myName}} from "@heroicons/react/solid";
Of course this doesn’t work but i just used it to express my goal. I know i could use a lib like react-svg and then do:
<ReactSVG src="/images/icons/myName.svg" />
But then i would need to copy all those SVGs into a target folder but i am already using the react heroicons components elsewhere. Would like to stick only with the heroicons react lib.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:22 (1 by maintainers)
Top Results From Across the Web
Dynamic Heroicons import with Next.js - Stack Overflow
I'm using heroicons in my Next.js project and since it currently doesn't support dynamic imports (by passing icon name to component) I ...
Read more >[Solved]-Dynamic Heroicons import with Next.js-Reactjs
Can i import the SVG file as a react component with dynamic import() Expressions? Conditionally import module using next js dynamic import, SSR...
Read more >A utility library to lookup TailwindCSS Heroicons by their name
If you need to import an icon dynamically based on it's name, you can with this library. By using the function below, you...
Read more >React dynamic component from array - Stack Overflow
I have an list of menu: import { HomeIcon } from '@heroicons/react/outline' export const menus = [ { name: 'Home', to: '/', desc:...
Read more >React Dynamic Imports and How To Use Them - Common Ninja
In this article, we are going to discuss dynamic imports, how to dynamically render components in React, and when to use dynamic imports....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is how I did it, quick but it works for what I needed.
Usage:
I needed dynamic import for Vue. Perhaps someone finds this useful: