1.0.2 • Published 5 years ago
mudkib v1.0.2
Action Generator
Trying to avoid collisions of actions using react-redux
/// actionTypes.js
import { generate } from "action-generator"
export const actionTypes = {
INCREMENT: generate("INCREMENT"),
}
/// actions.js
import { actionTypes } from "./actionTypes";
export const increment = () => {
return {
type: actionTypes.INCREMENT,
}
}
/// reducer.js
import { actionTypes } from "actionTypes"
...
switch (type) {
case actionTypes.INCREMENT: {
return state + 1
}
}