next-dynamic-loading-props

Pass props to the loading components in next/dynamic

Usage no npm install needed!

<script type="module">
  import nextDynamicLoadingProps from 'https://cdn.skypack.dev/next-dynamic-loading-props';
</script>

README

next-dynamic-loading-props

Pass props to the loading components in next/dynamic

Installation

npm install next-dynamic-loading-props

Usage

import dynamic from 'next/dynamic';
import withLoadingProps from 'next-dynamic-loading-props';

const Modal = withLoadingProps(useLoadingProps => dynamic(
  () => import('./modal'),
  {
    ssr: false,
    loading: () => {
      const props = useLoadingProps();
      return <Loading {...props} />
    }
  }
));

<Modal {...loadingProps} />