Skip to content

Instantly share code, notes, and snippets.

@MeetMartin
Last active July 25, 2021 06:31
Show Gist options
  • Save MeetMartin/6b21f799339931cc5fdfa8074424fe10 to your computer and use it in GitHub Desktop.
Save MeetMartin/6b21f799339931cc5fdfa8074424fe10 to your computer and use it in GitHub Desktop.
// src/store/reducers.js
import types from "./types";
const initialState = {
quote: 'Creativity is intelligence having fun.',
author: 'Albert Einstein'
};
const reducer = (state = initialState, action) => {
console.debug('[reducer]', action.type);
switch (action.type) {
case(types.RECEIVE_RANDOM_QUOTE):
return ({
...state,
quote: action.payload.quote,
author: action.payload.author
});
default:
return state;
}
};
export { initialState, reducer };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment