Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
redux-module
Advanced tools
Reduced boilerplate for your redux, inspired from Ducks: Redux Reducer Bundles and personally felt the pain of writing too much boilerplate for simple redux apps.
// sideNav.js
// Simple module that is suppose to open and close SideNavigation (hamburger menu) of an app.
import reduxModule from 'redux-module';
const module = reduxModule({
initialState: {
isSideNavOpen: false
},
reducers: {
openSideNav: (state) => ({ ...state, isSideNavOpen: true }),
closeSideNav: (state) => ({ ...state, isSideNavOpen: false })
}
});
export default module;
import { combineReducers } from 'redux';
import { getReducersFromModules } from 'redux-module';
import * as allModules from '/modules/index';
export default combineReducers(getReducersFromModules(allModules));
import { getReducerFromModule } from 'redux-module';
const reducer = getReducerFromModule(allModules);
import { connect } from 'react-redux';
import { actions } from 'mobile/modules/appState';
@connect(state => ({ appState: state.appState }))
class App extends Component {
render() {
const { appState, dispatch } = this.props;
return (
<div>
<button onClick={() => dispatch({type: actions.openSideNav})} >Open SideNav</button>
<SideNavigation isSideNavOpen={appState.isSideNavOpen} />
</div>
);
}
}
Redux Modules auto generates mirrored key value actions based on function names provided in reducers
object when creating Redux Module.
For above reducer you will have following actions available,
import { actions } from 'mobile/modules/appState';
console.log(actions); //{ openSideNav: 'openSideNav', closeSideNav: 'closeSideNav' }
You can now use these actions in your usual way ie,
import { actions } from 'mobile/modules/appState';
// somewhere in the component
dispatch({type: actions.openSideNav})
FAQs
Reduced boilerplate for redux
The npm package redux-module receives a total of 0 weekly downloads. As such, redux-module popularity was classified as not popular.
We found that redux-module 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.