question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get the store in _app.js

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kirill-konshincommented, Jul 30, 2020

@frankrod the other way: wrapper.withRedux(connect()(MyApp)). Wrapper has to wrap connected component.

1reaction
frankrodcommented, Jul 28, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found