1

I am building a React app with sagas for Redux and next.js. The main app.js file is handled as follows:

import { wrapper } from '../state/store';

const App = ({ Component, pageProps }) => (
  <Layout>
    <Component {...pageProps} />
  </Layout>
);


export default wrapper.withRedux(App);

I can call and write to the state using dispatch for the pages in this app and some of their direct children. However, with others I get an error that is always something like ...

Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider>

I don't understand how the parent page and some children are fine, but others have problems. It seems like components must be registered somewhere to be in the provider as every new component that I add has problems.

If the app is not wrapped in a provider, why does it work in the main page and some children? If it is wrapped, why aren't some components seeing that?

Joshua Foxworth
  • 1,112
  • 1
  • 16
  • 40
  • I don't see much of your code, but usually you want to connect your component to the store: see;https://react-redux.js.org/api/connect – Danys Chalifour Mar 23 '21 at 22:24
  • Connecting the store to the component should be something that Sagas does. I think that is where the problem lies – Joshua Foxworth Mar 23 '21 at 22:28
  • I'm not too familiar with next.js. If there is a site-wide `App` component then you want to put the `Provider` around that. If every page is independent then to the solution is probably similar to this answer that I wrote regarding gatsby: https://stackoverflow.com/a/66415186/10431574 – Linda Paiste Mar 24 '21 at 00:27
  • Kinda awkward finding a good place to ask, so AIA -- Joshua, what led you to [delete this question from yesterday](https://stackoverflow.com/q/66787874/1028230)? Kinda reduces the impetus to answer if you're going to delete questions (and therefore our answers too!) a few hours later. – ruffin Mar 25 '21 at 13:36
  • There are too many moving parts associated with Visual Studio and it was obvious that no one would be able to figure out what the problem was with JSLint. In the end, I decided that the extension maybe just doesn't do what I thought it would do. – Joshua Foxworth Mar 25 '21 at 14:19

0 Answers0