facebookarchive / redux-react-hook

React Hook for accessing state and dispatch from a Redux store
MIT License
2.16k stars 103 forks source link

How to use this with NextJS? #46

Closed sandervspl closed 5 years ago

sandervspl commented 5 years ago

I'm trying to get this library to work on my NextJS project, but so far it's not working. I have set up Redux exactly like the NextJS example, for reference. That implementation works fine.

This is my _app.tsx component

<Container>
  <StoreContext.Provider value={reduxStore}>
    <Component {...pageProps} />
  </StoreContext.Provider>
</Container>

The error that I get is redux-react-hook requires your Redux store to be passed through context via the <StoreContext.Provider>

Did anyone get this to work with NextJS yet? Or does anyone have an idea how it might work with NextJS / SSR?

ianobermiller commented 5 years ago

Can you provide a CodeSandbox with a repro? Is it possible you are creating two different StoreContext instances? Closing because this is likely a configuration issue, but I'll continue to respond.

sandervspl commented 5 years ago

I recreated the problem in the following codesandbox https://codesandbox.io/s/k901x91nzv I followed the NextJS Redux example for it.

thomasdola commented 5 years ago

any update on this issue? getting the same error...

ianobermiller commented 5 years ago

I'm not seeing any error when running that codesandbox -- {isLoading: false} is correctly logged to the console.