Skip to content

Commit d4ae7b4

Browse files
committed
Update README.md
1 parent e6d67d7 commit d4ae7b4

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Performant and flexible.
1818
- [API](#api)
1919
- [`<Provider store>`](#provider-store)
2020
- [`connect([mapStateToProps], [mapDispatchToProps], [mergeProps])`](#connectmapstatetoprops-mapdispatchtoprops-mergeprops)
21+
- [Troubleshooting](#troubleshooting)
2122
- [License](#license)
2223

2324
## React Native
@@ -391,6 +392,50 @@ function mergeProps(stateProps, dispatchProps, parentProps) {
391392
export default connect(mapStateToProps, actionCreators, mergeProps)(TodoApp);
392393
```
393394

395+
## Troubleshooting
396+
397+
Make sure to check out [Troubleshooting Redux](http://gaearon.github.io/redux/docs/Troubleshooting.html) first.
398+
399+
### My views aren’t updating!
400+
401+
See the link above.
402+
In short,
403+
404+
* Reducers should never mutate state, they must return new objects, or React Redux won’t see the updates.
405+
* Make sure you either bind action creators with `mapDispatchToState` argument to `connect()` or with `bindActionCreators()` method, or that you manually call `dispatch()`. Just calling your `MyActionCreators.addTodo()` function won’t work because it just *returns* an action, but not *dispatches* it.
406+
407+
### My views aren’t updating on route change with React Router 0.13
408+
409+
If you’re using React Router 0.13, you might [bump into this problem](https://github.com/gaearon/react-redux/issues/43). The solution is simple: whenever you use `<RouteHandler>` or the `Handler` provided by `Router.run`, pass the router state to it.
410+
411+
Root view:
412+
413+
```js
414+
Router.run(routes, Router.HistoryLocation, (Handler, routerState) => { // note "routerState" here
415+
React.render(
416+
<Provider store={store}>
417+
{() => <Handler routerState={routerState} />} // note "routerState" here
418+
</Provider>, document.getElementById('root'));
419+
});
420+
```
421+
422+
Nested view:
423+
424+
```js
425+
render() {
426+
// Keep passing it down
427+
return <RouteHandler routerState={this.props.routerState} />;
428+
}
429+
```
430+
431+
Conveniently, this gives your components access to the router state!
432+
You can also upgrade to React Router 1.0 which shouldn’t have this problem. (Let us know if it does!)
433+
434+
### I have some weird context error
435+
436+
If you have context issues, [make sure you don’t have duplicate React](https://medium.com/@dan_abramov/two-weird-tricks-that-fix-react-7cf9bbdef375) on the page.
437+
Also make sure you didn’t forget to wrap your root component in [`<Provider>`](#provider-store).
438+
394439
## License
395440

396441
MIT

0 commit comments

Comments
 (0)