Get the store in _app.js
See original GitHub issueHi, first of all, thanks for this HOC.
Is your feature request related to a problem? Please describe. I need to use next-redux-wrapper with redux-oidc because I have to manage the OpenID-Connect user auth. I’ve just use redux-oidc for other project (SPA without Next) and it works good. Here a simple example from doc:
<Provider store={store}>
<OidcProvider store={store} userManager={userManager}>
...
</OidcProvider>
</Provider>
It simple use a Provider that need the store.
This is the basic code with next-redux-wrapper:
const App = ({ Component, pageProps }) => {
return <Component {...pageProps} />;
}
export default wrapper.withRedux(App);
Describe the solution you’d like I’d like if the wrapper return the children component with the store as a props:
return (
<Provider store={store.current}>
<Component {...initialProps} {...resultProps} store={store.current} />
</Provider>
);
so I can write something like this:
const App = ({ Component, pageProps, store }) => {
return <OidcProvider store={store} userManager={userManager}>
<Component {...pageProps} />
</OidcProvider>;
}
export default wrapper.withRedux(App);
Describe alternatives you’ve considered if there are other solutions any help is welcome.
Additional context here part of package.json:
"next": "^9.4.0",
"next-redux-wrapper": "^6.0.1",
"oidc-client": "^1.10.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-oidc": "^4.0.0-beta1",
"redux-thunk": "^2.3.0",
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to access redux state in App.js (React-Native)
first, we dispatch some action from App.js through store directly. like we have some action in our epic folder like this
Read more >Accessing the Store | React Redux
Accessing the Store. React Redux provides APIs that allow your components to dispatch actions and subscribe to data updates from the store.
Read more >Is it possible to access my redux store in App/index.js? #1778
I have access to all information from my global selector. But I am not sure how to pass these as props to my...
Read more >Getting Data Out of the Redux Store with Selectors
In a Mobify Progressive Web App, we always use selectors to get data from the Redux store rather than accessing the Redux store...
Read more >How to Manage State in a React App – With Hooks, Redux ...
Plain JavaScript functions don't have the ability to store information. ... App.js import { useState } from 'react' function App() { const ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@frankrod the other way:
wrapper.withRedux(connect()(MyApp))
. Wrapper has to wrap connected component.Is there a way to access the store when my _app.js is a class component? I would like to call store.dispatch inside _app.js componentDidUpdate method