Skip to content

Instantly share code, notes, and snippets.

@JamesTheHacker
Created October 12, 2017 16:10
Show Gist options
  • Save JamesTheHacker/280b75dde808351831798e770c06e797 to your computer and use it in GitHub Desktop.
Save JamesTheHacker/280b75dde808351831798e770c06e797 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;
}
}
// Default state
const initialState = {
fetchingTweets: false,
tweets: []
};
// Create state store
const store = new FauxRedux(reducer, initialState);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment