Flux actions

"Now we need to define the actions types that we are going to refer to as constants at various places, such as sending the type from Actions to store, and in our store, deciding what action type has been passed to store to take appropriate actions.

//SocialConstants.js
var keyMirror = require('keymirror');

module.exports = keyMirror({
  FILTER_BY_TWEETS: null,
  FILTER_BY_REDDITS: null,
  SYNC_TWEETS: null,
  SYNC_REDDITS: null

});

"Here, we are using the https://github.com/STRML/keyMirror package to create keys and values for the object based on the keys. This will convert into object similar to below."

{
FILTER_BY_TWEETS: 'FILTER_BY_TWEETS', 
…
}

"This is handy when adding new keys to not repeat the same contents again."

"We can now start using ...

Get ReactJS by Example - Building Modern Web Applications with React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.