I want to import react-icons dynamically.
This works in Javascript, but how do i convert this to Typescript without getting all sorts of errors?
Code:
import * as ReactIcons from 'react-icons/all';
const getIcon = (icon) => {
const TagName = ReactIcons[icon];
return <TagName />;
};
Here is output from .d.ts files from react-icons if that helps:
// node_modules/react-icons/all.d.ts
export * from './fa';
export * from './fa';
export * from './io';
export * from './md';
export * from './ti';
export * from './go';
export * from './fi';
export * from './gi';
export * from './gi';
export * from './gi';