babel-plugin-s2s-reducer-case-creater
v1.0.1
Published
create reducer case using action types
Downloads
31
Readme
babel-plugin-s2s-reducer-case-creater
s2s plugin: create reducr case pattern using actionTypes
Install
$ npm install --save-dev babel-plugin-s2s-reducer-case-creater
Example
actionTypes.js
export const Actions = {
INCREMENT,
DECREMENT,
}
IN:
export default function(state: State = initialState, action) {
switch (action.type) {
case Actions.INCREMENT:
return { ...state, count: state + 1 }
default:
return state
}
}
OUT:
export default function(state: State = initialState, action) {
switch (action.type) {
case Actions.DECREMENT:
return {
...state,
}
case Actions.INCREMENT:
return { ...state, count: state + 1 }
default:
return state
}
}
And, Just change {...state}
→ {...state, count: staet - 1}
.
Usage
{
['s2s-reducer-case-creater']
}
from
type: string
required: true
actionTypes.js path
If you use s2s
, you don't use this option. s2s handle it automatically.