react-lazy-icons
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.1 • Public • Published

    react-lazy-icons

    import React from 'react';
    import ReactDOM from 'react-dom';
    import { createIconComponents } from 'react-lazy-icons';
    import { IconsPaths } from './generated/icons';
     
    const loadIcons = () => import('./generated/icons');
     
    const { Icon, IconsProvider } = createIconComponents<IconsPaths>();
     
    const App: React.FC = () => {
      return (
        <div>
          <span>Some Text</span>
          <Icon icon="home" iconSize={35} />
          <span>just to make sure the flow stay the same</span>
          <Icon icon="chevron-left" color="red" />
          <Icon icon="chevron-left" color="blue" />
          <Icon icon="chevron-left" color="green" />
        </div>
      );
    };
     
    const IconsManager: React.FC = ({ children }) => {
      const [icons, setIcons] = React.useState<null | IconsPaths>(null);
     
      React.useEffect(() => {
        setTimeout(() => {
          loadIcons().then(icons => {
            setIcons(icons.ICONS_PATHS);
          });
        }, 2000);
      }, []);
     
      return <IconsProvider iconsPaths={icons}>{children}</IconsProvider>;
    };
     
    ReactDOM.render(
      <IconsManager>
        <App />
      </IconsManager>,
      document.getElementById('root')
    );

    Keywords

    none

    Install

    npm i react-lazy-icons

    DownloadsWeekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    35.4 kB

    Total Files

    15

    Last publish

    Collaborators

    • etienne-dldc