Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-navigation-sxf-redux-helpers
Advanced tools
Redux middleware and utils for React Navigation
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!)yarn add react-navigation-redux-helpers
or
npm install --save react-navigation-redux-helpers
import {
createStackNavigator,
} from 'react-navigation';
import {
createStore,
applyMiddleware,
combineReducers,
} from 'redux';
import {
createReduxContainer,
createReactNavigationReduxMiddleware,
createNavigationReducer,
} from 'react-navigation-redux-helpers';
import { Provider, connect } from 'react-redux';
import React from 'react';
const AppNavigator = createStackNavigator(AppRouteConfigs);
const navReducer = createNavigationReducer(AppNavigator);
const appReducer = combineReducers({
nav: navReducer,
...
});
const middleware = createReactNavigationReduxMiddleware(
state => state.nav,
);
const App = createReduxContainer(AppNavigator);
const mapStateToProps = (state) => ({
state: state.nav,
});
const AppWithNavigationState = connect(mapStateToProps)(App);
const store = createStore(
appReducer,
applyMiddleware(middleware),
);
class Root extends React.Component {
render() {
return (
<Provider store={store}>
<AppWithNavigationState />
</Provider>
);
}
}
createReactNavigationReduxMiddleware
(required)function createReactNavigationReduxMiddleware<State: {}>(
navStateSelector: (state: State) => NavigationState,
key?: string,
): 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)function createReduxContainer(
navigator: Navigator,
key?: string,
): 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)function 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
:
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|@?react-navigation|react-navigation-redux-helpers)"
]
}
Here is a code snippet that demonstrates how the user might handle the hardware back button on platforms like Android:
import React from "react";
import { BackHandler } from "react-native";
import { NavigationActions } from "react-navigation";
/* your other setup code here! this is not a runnable snippet */
class ReduxNavigation extends React.Component {
componentDidMount() {
BackHandler.addEventListener("hardwareBackPress", this.onBackPress);
}
componentWillUnmount() {
BackHandler.removeEventListener("hardwareBackPress", this.onBackPress);
}
onBackPress = () => {
const { dispatch, nav } = this.props;
if (nav.index === 0) {
return false;
}
dispatch(NavigationActions.back());
return true;
};
render() {
/* more setup code here! this is not a runnable snippet */
return <AppNavigator navigation={navigation} />;
}
}
FAQs
Redux middleware and utils for React Navigation
The npm package react-navigation-sxf-redux-helpers receives a total of 1 weekly downloads. As such, react-navigation-sxf-redux-helpers popularity was classified as not popular.
We found that react-navigation-sxf-redux-helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.