redux-su
v0.3.4
Published
Redux simple utils
Downloads
11
Readme
Redux Simple Utils
Description
Package with useful utils for Redux.
Connect decorator
Replacement for react-redux
connect
Usage:
import {connect} from 'redux-su';
import actions from './redux/actions'; // { user: { auth: () => {}, login: () => {} ... }, ... [actionGroup] : { [actionName] : [actionFunc], ...} }
const selectors = {
byPath: 'user.todos[0].title',
byFunc: (store) => store.user.todos[0].title,
};
@connect(selectors, actions)
class Test extends React.Component {
render () {
return (
<ul>
<li>By path: {this.props.byPath}</li>
<li>By function: {this.props.byFunc}</li>
</ul>
);
}
}
Create Reducer helper
Small helper for reducer
Usage:
import {createReducer} from 'redux-su';
export default const Reducer = createReducer({
'ACTION_1': (store, action) => ({...store, action1: 'fired!'}),
'ACTION_2': (store, action) => ({...store, action2: action.payload}),
});