Gathering detailed insights and metrics for react-navigation-sxf-redux-helpers
Gathering detailed insights and metrics for react-navigation-sxf-redux-helpers
npm install react-navigation-sxf-redux-helpers
Typescript
Module System
Node Version
NPM Version
67.1
Supply Chain
97.8
Quality
74.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
416
Last Day
1
Last Week
3
Last Month
11
Last Year
48
NOASSERTION License
1 Commits
2 Watchers
1 Branches
1 Contributors
Updated on Nov 21, 2019
Latest Version
1.0.0
Package Id
react-navigation-sxf-redux-helpers@1.0.0
Unpacked Size
17.94 kB
Size
5.67 kB
File Count
9
NPM Version
6.11.3
Node Version
12.12.0
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
50%
3
Compared to previous week
Last Month
266.7%
11
Compared to previous month
Last Year
-15.8%
48
Compared to previous year
This package allows the user to manage their React Navigation state from within Redux.
Most projects that are using both Redux and React Navigation don't need this library. Things like state persistence and BackHandler
behavior aren't handled directly by createReduxContainer
, but are handled by the default createAppContainer
. However, there are some things this library makes easier:
isTransitioning
to true!)1yarn add react-navigation-redux-helpers
or
1npm install --save react-navigation-redux-helpers
1import { 2 createStackNavigator, 3} from 'react-navigation'; 4import { 5 createStore, 6 applyMiddleware, 7 combineReducers, 8} from 'redux'; 9import { 10 createReduxContainer, 11 createReactNavigationReduxMiddleware, 12 createNavigationReducer, 13} from 'react-navigation-redux-helpers'; 14import { Provider, connect } from 'react-redux'; 15import React from 'react'; 16 17const AppNavigator = createStackNavigator(AppRouteConfigs); 18 19const navReducer = createNavigationReducer(AppNavigator); 20const appReducer = combineReducers({ 21 nav: navReducer, 22 ... 23}); 24 25const middleware = createReactNavigationReduxMiddleware( 26 state => state.nav, 27); 28 29const App = createReduxContainer(AppNavigator); 30const mapStateToProps = (state) => ({ 31 state: state.nav, 32}); 33const AppWithNavigationState = connect(mapStateToProps)(App); 34 35const store = createStore( 36 appReducer, 37 applyMiddleware(middleware), 38); 39 40class Root extends React.Component { 41 render() { 42 return ( 43 <Provider store={store}> 44 <AppWithNavigationState /> 45 </Provider> 46 ); 47 } 48}
createReactNavigationReduxMiddleware
(required)1function createReactNavigationReduxMiddleware<State: {}>( 2 navStateSelector: (state: State) => NavigationState, 3 key?: string, 4): Middleware<State, *, *>;
navStateSelector
selects the navigation state from your store.key
needs to be unique for the Redux store and consistent with the call to createReduxContainer
below. You can leave it out if you only have one store.createReduxContainer
(required)1function createReduxContainer(
2 navigator: Navigator,
3 key?: string,
4): React.ComponentType<{ state: NavigationState, dispatch: Dispatch }>;
navigator
is your root navigator (React component).key
needs to be consistent with the call to createReactNavigationReduxMiddleware
above. You can leave it out if you only have one store.state
and dispatch
props that you get via react-redux
's connect
.createNavigationReducer
(optional)1function createNavigationReducer(navigator: Navigator): Reducer<*, *>;
createNavigationReducer
in the global scope to construct a navigation reducer.navigator.router.getStateForAction
, which you can call directly if you'd prefer.navigator
is your root navigator (React component).combineReducers
.To make Jest tests work with your React Navigation app, you need to change the Jest preset in your package.json
:
1"jest": { 2 "preset": "react-native", 3 "transformIgnorePatterns": [ 4 "node_modules/(?!(jest-)?react-native|@?react-navigation|react-navigation-redux-helpers)" 5 ] 6}
Here is a code snippet that demonstrates how the user might handle the hardware back button on platforms like Android:
1import React from "react"; 2import { BackHandler } from "react-native"; 3import { NavigationActions } from "react-navigation"; 4 5/* your other setup code here! this is not a runnable snippet */ 6 7class ReduxNavigation extends React.Component { 8 componentDidMount() { 9 BackHandler.addEventListener("hardwareBackPress", this.onBackPress); 10 } 11 12 componentWillUnmount() { 13 BackHandler.removeEventListener("hardwareBackPress", this.onBackPress); 14 } 15 16 onBackPress = () => { 17 const { dispatch, nav } = this.props; 18 if (nav.index === 0) { 19 return false; 20 } 21 22 dispatch(NavigationActions.back()); 23 return true; 24 }; 25 26 render() { 27 /* more setup code here! this is not a runnable snippet */ 28 return <AppNavigator navigation={navigation} />; 29 } 30}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/1 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More