redux-lazy
v0.6.1
Published
redux-lazy
Downloads
41
Maintainers
Readme
redux-lazy
Generating constants, action types, action creators, reducers and containers for you.
How to install
npm i -S redux-lazy
How to use
import RL from 'redux-lazy';
const rl = new RL('post');
rl.addAction('title', { title: '' });
const {
nameSpace,
types,
actions,
defaultState,
reducer,
mapStateToProps,
mapDispatchToProps,
Container,
} = rl.flush();
React example
import React from 'react';
import RL from 'redux-lazy';
const rl = new RL('post');
rl.addFormAction('submit');
rl.addFormElementAction('title');
const { Container, reducer } = rl.flush();
const FormComponent = props => (
<form onSubmit={props.submitAction}>
<input
type="text"
value={props.title}
onChange={props.titleAction}
/>
</form>
);
export default Container(FormComponent);
export { reducer };
Just add reducer to redux and this example should work.
Articles
React — redux for lazy developers:
React/Redux development on steroids