lazyLoad.stories.js 559 B

12345678910111213141516171819
  1. import React from 'react';
  2. import {storiesOf} from '@storybook/react';
  3. import {withInfo} from '@storybook/addon-info';
  4. import LazyLoad from 'app/components/lazyLoad';
  5. storiesOf('Utility|LazyLoad', module).add(
  6. 'LazyLoad',
  7. withInfo('Lazy loads a view/component')(() => {
  8. const MyComponent = () => (
  9. <div>View that is loaded after 1000ms to simulate dynamic import</div>
  10. );
  11. const getComponent = () =>
  12. new Promise(resolve => setTimeout(() => resolve(MyComponent), 1000));
  13. return <LazyLoad component={getComponent} />;
  14. })
  15. );