Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

reactjs - Could not find react-redux context value

I'm trying to do my exportable package in which I create the redux store. The entry point of my package component expects an application given from another project. Here's the code of the package:

<Provider store={store}>
     <IntlProvider messages={messages} locale={locale} defaultLocale={config.defaultLanguage}>
    {app}
   </IntlProvider>
</Provider>

The package entry point is this:

<MyCore withLogs={false} applicationSagas={appSagas} applicationReducers={appReducers} app={<App />} />

Ok. If I use the following code inside my package code and I use useSelector or useDispatch everything works fine, but if I use the same code in an external project (obviously after installed my package) I encounter this error:

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

How can I solve this and use a store outside the package code?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...