
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
redux-container-builder
Advanced tools
A simpler fluent interface to redux's connect with support for custom HOC's
Receives the react component to wrap.
A shorthand version of redux's mapStateToProps. Each key in mappingObject describes a prop name, and each correspending value is a selector function that expects the redux state tree as a single parameter.
Calling this method or mapDispatchToProps() will wrap the component in redux's connect method.
A shorthand version of redux's mapDispatchToProps. Each key in mappingObject describes a prop name, and each correspending value is a function that will be later invoked and wrapped with dispatch().
Calling this method or mapStateToProps() will wrap the component in redux's connect method.
Attach a special one-off higher-order component. HOC's will be applied in the same order as the calls to withWrapper For a more powerful approach, check out Extending the builder.
Builds the component!
import ContainerBuilder from 'redux-container-builder';
export default new ContainerBuilder(MonthlyExpenseReport)
.mapStateToProps({
report: getReport,
groupedExpenses: getGroupedExpenses,
isSaving: getIsSaving
})
.mapDispatchToProps({
goBack: () => push('/'),
saveReport: report => actions.save.request(report),
tagCategory: ({ id, category }) => actions.tagCategory({ id, category })
})
.withWrapper(CustomHOCLibrary())
.build();
It is possible to extend the container builder with your own methods, each one supplying a custom higher-order component you use often in your app.
This can be achived with a static method extend.
name: The method name we will attach to the container builder.
extendCallback: A function that accepts another callback as its single argument. This second callback must be passed a third function that can be invoked from every ContainerBuilder instance, and returns a custom HOC.
After finishing nursing a new headache having imagined all these callbacks, please see the example below.
shouldRunBeforeConnect: Should the HOCs constructed by the extension methods applied before (or above) the react-redux connect HOC. Pretty much only useful if your HOC uses redux-connect itself and its props must be updated before the original component's. (e.g. redux-fetch-on-mount)
Note: extend() calls can be chained.
Another Note: HOC's are applied to components in the same order that their factory methods are called on the ComponentBuilder instance.
In order to tap into the translations capabilities of react-i18next, a higher-order-component must be applied to your react components. (Docs)
Here's how to extend ContainerBuilder with a custom "withTranslations" method that does just that:
boostrap.js:
import ContainerBuilder from 'redux-container-builder';
import { translate } from 'react-i18next';
ContainerBuilder.extend('withTranslations', addToBuilder => {
addToBuilder(namespace => translate(namespace));
});
...
ImportantComponent.js:
export default new ContainerBuilder(ImportantComponent)
.withTranslations('ImportantComponent-translation-namespace')
.mapStateToProps({
report: getImportantDataSelector
})
.component;
FAQs
A simpler fluent interface to redux's connect
We found that redux-container-builder 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.