News for hackers. Stuff that matters.
Re:Build Yourself a Redux by chucksmash on Friday May 05, 2017 @02:36PM (#14275741)
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(...));

There are no comments on this comment yet.