Skip to content

Commit

Permalink
Update FAQ for react native example (#363)
Browse files Browse the repository at this point in the history
* Update FAQ for react native example
  • Loading branch information
arnaud-zg authored and supasate committed Nov 17, 2019
1 parent 06c9a10 commit c796978
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [How to hot reload reducers](#how-to-hot-reload-reducers)
- [How to support Immutable.js](#how-to-support-immutablejs)
- [How to migrate from v4 to v5/v6](#how-to-migrate-from-v4-to-v5v6)
- [How to use connected-react-router with react native](#how-to-use-connected-react-router-with-react-native)
- [How to use your own context with react-redux](#how-to-use-your-own-context-with-react-redux)

### How to navigate with Redux action
Expand Down Expand Up @@ -309,6 +310,36 @@ It's easy to migrate from v4 to v5/v6.
+ store.replaceReducer(nextCreateRootReducer(history))
```

### How to use connected-react-router with react native
#### History does not exist, how can I configure my redux store?
As you know react native does not support natively the HTML5 history API, it's supposed to be available only for web browsers. This issue can be solved by using [`createMemoryHistory`](https://github.com/ReactTraining/history/blob/master/docs/GettingStarted.md#intro).

Here is an example with react-redux v6.0.0.

```js
const history = createMemoryHistory()

ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<Route path="/" component={myComponent} exact={true} />
</ConnectedRouter>
</Provider>
)
```

[Example available here](./examples/react-native/src/configureStore.js)

#### Get location from a screen
You can access at your location interface with `history.location`.

[Example available here](./examples/react-native/src/screens/Account.js)

#### Go to a screen with parameter
You can use `history` and navigate between screens.

[Example available here](./examples/react-native/src/screens/Home.js)

### How to Use Your Own Context with react-redux
With react-redux v6.0.0, you can pass your own context to `<Provider>` component. So, you need to pass the same context as props to `<ConnectedRouter>` component.
```js
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ See the [examples](https://github.com/supasate/connected-react-router/tree/maste
- [How to support Immutable.js](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-support-immutablejs)
- [How to implement server-side rendering](https://medium.com/@cereallarceny/server-side-rendering-in-create-react-app-with-all-the-goodies-without-ejecting-4c889d7db25e) ([sample codebase](https://github.com/cereallarceny/cra-ssr))
- [How to migrate from v4 to v5](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-migrate-from-v4-to-v5)
- [How to use connected-react-router with react native](./FAQ.md#how-to-use-connected-react-router-with-react-native)
- [How to use your own context with react-redux](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-use-your-own-context-with-react-redux)

Build
Expand Down

0 comments on commit c796978

Please sign in to comment.