mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-24 17:18:09 +00:00
* add jest config for react-navigation in docs (#256) * Docs: Update redux-integration guide #246
This commit is contained in:
parent
83f8a44219
commit
e8726c1e68
@ -11,7 +11,7 @@ const AppNavigator = StackNavigator(AppRouteConfigs);
|
||||
|
||||
const navReducer = (state, action) => {
|
||||
const newState = AppNavigator.router.getStateForAction(action, state);
|
||||
return newState || state;
|
||||
return (newState ? newState : state)
|
||||
};
|
||||
|
||||
const appReducer = combineReducers({
|
||||
@ -61,3 +61,16 @@ const AppNavigator = StackNavigator({
|
||||
```
|
||||
|
||||
In this case, once you `connect` `AppNavigator` to Redux as is done in `AppWithNavigationState`, `MyTabNavigator` will automatically have access to navigation state as a `navigation` prop.
|
||||
|
||||
## Mocking tests
|
||||
|
||||
To make jest tests work with your react-navigation app, you need to change the jest preset in the `package.json`, see [here](https://facebook.github.io/jest/docs/tutorial-react-native.html#transformignorepatterns-customization):
|
||||
|
||||
```
|
||||
"jest": {
|
||||
"preset": "react-native",
|
||||
"transformIgnorePatterns": [
|
||||
"node_modules/(?!(jest-)?react-native|react-navigation)"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user