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.

v4.4.4 appears to prevent components from receiving context changes

See original GitHub issue

I have a project based on https://github.com/erikras/react-redux-universal-hot-example and one of my components needs to check router.isActive(someUrl) whenever a route changes and update its style/markup. The router object is accessible from components via context. Since react-redux v4.4.4 the component no longer updates (render, shouldComponentUpdate, componentWillReceiveProps are not called) on route change.

I’ve specifically checked that it works with <= v4.4.3 and not with >= v4.4.4.

The essential code of the component is:

class Item extends Component {
  static contextTypes = {
    router: PropTypes.object
  };

  render() {
    return (
      <div>{this.context.router.isActive(this.props.url) ? 'yes' : 'no'}</div>
    );
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, May 13, 2016

@landabaso React Redux only uses context for dependency injection of the store. The future updates work because Child subscribes to the store directly via store.subscribe() API.

@krukid I sent a few PRs to fix this in React Router, and it won’t be an issue in 3.0 anymore.

1reaction
gaearoncommented, Apr 29, 2016

Sorry but 2.4.0 had no relation to this issue. withRouter that was added there just exposes context as a prop but it doesn’t affect how that context is actually updated.

https://github.com/reactjs/react-router/issues/470 is still open. This is the issue you want to be tracking.

I documented a workaround above. Please don’t “suffer”, just use { pure: false } in the meantime. This is exactly why it was added.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-admin - Upgrading to v4 - Marmelab
React-admin v4 now uses a context to keep the app basePath, so the basePath prop is no longer necessary. Every component that received...
Read more >
4.4 Nonverbal Communication in Context
Nonverbal communication receives less attention than verbal communication as a part of our everyday lives. Learning more about nonverbal communication and ...
Read more >
<uses-sdk> | Android Developers
Lets you express an application's compatibility with one or more versions of the Android platform, by means of an API Level integer.
Read more >
Links must have discernible text | Axe Rules - Deque University
Ensure that all link names are accessible. · Ensure all links can receive programmatic focus; for example, avoid device-specific events (for example, onmouseover...
Read more >
4.4 Existence of a significant financing component
A significant financing component may exist in an arrangement when a customer makes an advance payment because the reporting entity requires ...
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