1.0 KiB
1.0 KiB
title |
---|
Extract State Logic to Redux |
Extract State Logic to Redux
This is a stub. Help our community expand it.
This quick style guide will help ensure your pull request gets accepted.
Suggested solution:
const ADD = 'ADD';
function addMessage(message) {
return {
type: ADD,
message: message
};
};
function messageReducer (previousState, action) {
return [...previousState, action.message];
}
let store = {
state: [],
getState: () => store.state,
dispatch: (action) => {
if (action.type === ADD) {
store.state = messageReducer(store.state, action);
}
}
};