eBay / nice-modal-react

A modal state manager for React.
https://ebay.github.io/nice-modal-react
MIT License
1.96k stars 110 forks source link

Doesn't work well with NextJS #18

Closed RobinLbt closed 2 years ago

RobinLbt commented 2 years ago

I've tried to incorporate nice-modal-react on a NextJS project, but the provider doesn't work when wrapping the app at the root of the tree

function MyApp({ Component, pageProps: { session, ...pageProps }}) {
  return (
    <NiceModal.Provider>
      <Component {...pageProps} />
    </NiceModal.Provider>
  )
}

export default MyApp

It works when wrapping a single page with the provider, so the problem comes from the provider itself. Unfortunately, it's not a clean solution since I have to wrap every page with a Provider.

tech-ea commented 2 years ago

@RobinLbt I'm using NextJS and NiceMOdal, and I got it to work, but I am worried about performance. Are you still using NiceModal?Did you find a solution? thanks Drew

RobinLbt commented 2 years ago

No I've switched to a custom implementation to have more controls over it

dungle-scrubs commented 1 year ago

@RobinLbt I'm using NextJS and NiceMOdal, and I got it to work, but I am worried about performance. Are you still using NiceModal?Did you find a solution? thanks Drew

How were you able to get it to work with Nextjs? I have the same issue where it must be done at page-level and not within _app.js. Also, why are you worried about performance? Thanks