11 ms·
I usually handle this via text editor macros when I'm starting off Start with actionNames.txt ADD_TODO REMOVE_TODO Cat that file to actionTypes.js and a
by chucksmash 9y ago
I usually handle this via text editor macros when I'm starting off
Start with
actionNames.txt
ADD_TODO
REMOVE_TODO
Cat that file to actionTypes.js and actions.js. In actionTypes.js, expand:
<line> to:
export const <line> = "<line>"
And in actions.js, expand <line> to something like:
export const (camelcase-string <line>) = () => {
return {
type: types.<line>,
};
};
Also instead of importing actions and actionTypes individually, I'll generally do:
import * as actions from './actions';
import * as types from './actionTypes';
dispatch(actions.addTodo(...));