
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
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 10 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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.