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.

react-redux 6.0.0

See original GitHub issue

Just ran into an issue with the new way react-redux behaves. You can see more details about it in this thread: https://github.com/reduxjs/react-redux/issues/935#issuecomment-446515270

As we can see from the last release of react-redux 6.0.0: https://github.com/reduxjs/react-redux/releases

Behavior Changes
Any library that attempts to access the store instance out of legacy context will break, because we now put the store state into a <Context.Provider> instead. Examples of this include connected-react-router and react-redux-subspace. (The current implementation does also put the store itself into that same context. While accessing the store in context is not part of our public API, we will still try to make it possible for other libraries to access it, with the understanding that this could break at any time.)

This makes the onLoad function not working properly. The fourth parameter context is no more populated with the store. Although it is not a real issue for me, as I use redux-reducers-injector (I’m the maintainer), I have a reference of the store that I can use, and can use replaceReducer. The real issue is that even with injecting my reducer correctly, the mapStateToProps will not reflect this change in its first parameter state and I won’t be able to display my component correctly.

You can read more about this issue in the link I post above on the react-redux project: https://github.com/reduxjs/react-redux/issues/935#issuecomment-446515270

Feel free to ask me more information about this.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

1reaction
brokvolchanskycommented, Aug 5, 2019

I use RR with RUC in this way:

class App extends Component {
  render() {
    return (
      <ReactReduxContext.Consumer>
        {props => {
          return (
            <Switcher store={props.store} /> /* or even {...props} */ 
          )
        }}
      </ReactReduxContext.Consumer>
    )
  }
}

export default hot(module)(App)

and somewhere in Switcher.js:

let innerStore

const UniversalComponent = universal(determineHowToLoad, {
//...
  onLoad: (module, { isSync, isServer }, props, context) => {
    const { store } = props
    innerStore = store
  }
}

const Switcher = ({ store, page, type }) => (
  <UniversalComponent
    component={`${page}`}
    onAfter={onAfterChanged}
    type={type}
    store={store}
  />
)
0reactions
ScriptedAlchemycommented, Jan 14, 2019

If you would update the documentation on our end to point to those PRs or readmes that would be great information for us to have on hand!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

6.0.0 - react-redux - npm
Official React bindings for Redux. Latest version: 8.0.5, last published: 2 months ago. Start using react-redux in your project by running ...
Read more >
Compatibility with react-redux@^6.0.0 · Issue #417 - GitHub
I'm passing the store as a prop to the component returned by calling createDevTools and this is the scenario where I encounter the...
Read more >
Install react-redux with NPM - NPM Packages
Install react-redux with NPM. Official React bindings for Redux View react-redux source code on Github. ... react-redux package install - Version 6.0.0 ......
Read more >
react-redux vulnerabilities - Snyk
version published direct vulnerabilities 8.0.5 3 Nov, 2022 0. C. 0. H. 0. M. 0. L 8.0.4 22 Sep, 2022 0. C. 0. H. 0....
Read more >
Installation - Redux Form
redux -form works with React Redux to enable an html form in React to use Redux to store all of its state. Installation....
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