Skip to content

Commit f6b23fe

Browse files
committed
Update redux integration docs
1 parent ea3bc96 commit f6b23fe

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

docs/redux-integration.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ title: Redux integration
44
sidebar_label: Redux integration
55
---
66

7-
Some folks like to have their navigation state stored in the same place as the rest of their application state. Using Redux to handle your state enables you to write custom actions that manipulate the navigation state directly, to be able to dispatch navigation actions from anywhere (sometimes in a "thunk" or "saga"), and to persist the navigation state in the same way you would other Redux state (your mileage may vary on this). You can read more about other use cases in the replies to [this tweet](https://twitter.com/satya164/status/952291726521024512).
7+
Some folks like to have their navigation state stored in the same place as the rest of their application state. *Think twice before you consider doing this, there is an incredibly good chance that you do not need to do this!*. Storing your React Navigation state in your own Redux store is likely to give you a very difficult time if you don't know what you're doing, and support for Redux integration is being depreacted.
88

9-
## Warning!
10-
11-
*You probably do not need to do this!* Storing your React Navigation state in your own Redux store is likely to give you a very difficult time if you don't know what you're doing. You lose out on some performance optimizations that React Navigation can do for you, for example. Please do not integrate your state into Redux without first checking if you can do what you need to do without it!
9+
**In the next major version of React Navigation, to be released in Fall 2018, we will no longer provide any information about how to integrate with Redux and it may cease to work**. It may continue to work either by coincidence or will of the community, but it will not be tested against or considered when making any design decisions for the library.
1210

1311
## Overview
1412

@@ -22,6 +20,8 @@ Some folks like to have their navigation state stored in the same place as the r
2220

2321
## Step-by-step guide
2422

23+
The following steps apply to `react-navigation@^2.3.0` and `react-navigation-redux-helpers@^2.0.0-beta`.
24+
2525
First, you need to add the `react-navigation-redux-helpers` package to your project.
2626

2727
```bash
@@ -70,17 +70,18 @@ const middleware = createReactNavigationReduxMiddleware(
7070
const navigationPropConstructor = createNavigationPropConstructor("root");
7171

7272
class App extends React.Component {
73-
7473
componentDidMount() {
7574
initializeListeners("root", this.props.nav);
7675
}
7776

7877
render() {
79-
const navigation = navigationPropConstructor(
78+
this._navigation = navigationPropConstructor(
8079
this.props.dispatch,
8180
this.props.nav,
81+
AppNavigator.router,
82+
() => this._navigation
8283
);
83-
return <AppNavigator navigation={navigation} />;
84+
return <AppNavigator navigation={this._navigation} />;
8485
}
8586

8687
}

0 commit comments

Comments
 (0)