我正在为 Redux 和 next.js 构建一个带有 sagas 的 React 应用程序。主要的 app.js 文件处理如下:
import { wrapper } from '../state/store';
const App = ({ Component, pageProps }) => (
<Layout>
<Component {...pageProps} />
</Layout>
);
export default wrapper.withRedux(App);
我可以使用 dispatch 调用该应用程序中的页面及其一些直接子级的状态并写入状态。但是,对于其他人,我收到的错误总是类似于 ...
Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider>
我不明白父页面和一些子页面如何正常,但其他页面有问题。似乎组件必须在某个地方注册才能在提供程序中,因为我添加的每个新组件都有问题。
如果应用程序没有封装在提供程序中,为什么它可以在主页面和一些子页面中工作?如果它被包装了,为什么有些组件看不到它?