Situation: You have a big list of icons or images


Situation: You have a big list of icons or images. You want to dynamically display a few without importing them all.

Solution: Create a lazy loading wrapper.

Steps:
1. Lazy load all the options
2. Specify the component to render via a prop 🔥

#react

I call this a "Lazy loaded, strongly typed, component set wrapper.

I generate this component via a Node script that looks like this.

This way, the component is updated anytime we add new icons. 😎

Sure beats having to manually maintain an import containing a hundred icons!

View original on X