Skip to content

Instantly share code, notes, and snippets.

@JamesTheHacker
Created October 12, 2017 16:48
Show Gist options
  • Save JamesTheHacker/96c9e38393a0cf1c11eee92181ceb4fc to your computer and use it in GitHub Desktop.
Save JamesTheHacker/96c9e38393a0cf1c11eee92181ceb4fc to your computer and use it in GitHub Desktop.
// This is a reducer, same as Redux's
const reducer = (state, action) => {
switch(action.type) {
case 'FETCHING_TWEETS':
return {...state, fetchingTweets: true};
break;
case 'TWEETS_RECEIVED':
return { ...state,
fetchingTweets: false,
tweets: action.tweets
};
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment