schiehll / react-alert

alerts for React
MIT License
608 stars 98 forks source link

Support forwardRef as alert template #143

Closed StarpTech closed 4 years ago

StarpTech commented 4 years ago

Hi, I got an error when using dynamic imports in next.js

breadcrumbs.js:64 Warning: Failed prop type: Invalid prop `template` supplied to `Provider`.
    in Provider (at _app.jsx:72)
    in MyApp (created by AppWithTranslation)
    in NextStaticProvider (created by NamespacesConsumerComponent)
    in NamespacesConsumerComponent (created by WithMergedOptions)
    in WithMergedOptions (created by Context.Consumer)
    in WithMergedOptions(NamespacesConsumerComponent) (created by LoadNamespace)
    in LoadNamespace (created by WithMergedOptions)
    in WithMergedOptions (created by Context.Consumer)
    in LoadNamespace(NextStaticProvider) (created by AppWithTranslation)
    in I18nextProvider (created by AppWithTranslation)
    in AppWithTranslation (created by withRouter(AppWithTranslation))
    in withRouter(AppWithTranslation)
    in Container (created by AppContainer)
    in AppContainer
const AlertTemplate = dynamic(import('~/components/alert-template'), {
  ssr: false
});

  <AlertProvider
            template={AlertTemplate}

The propType must be updated to support forwardRefs

https://github.com/schiehll/react-alert/blob/5229d32e4060d4185e3174c63858b2d00e4730b7/src/Provider.js#L160

to

template: PropTypes.oneOfType([PropTypes.element, PropTypes.func, PropTypes.elementType]).isRequired,
schiehll commented 4 years ago

Fixed in the last release.

StarpTech commented 4 years ago

Thanks!