Created
March 1, 2020 17:15
-
-
Save Godefroy/54ae0378a57919f02ec6fa519f4fc05b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { prepareStore } from 'redux-zap' | |
const initialState = { | |
count: 0, | |
counting: false | |
} | |
export default prepareStore(initialState, { | |
// Action "reset" that set count to 0 | |
// We return a partial state that will be applied to the current state | |
reset: () => ({ count: 0 }), | |
// Action "increment" that increments the count | |
// We need the previous state, we can get it by returning a function | |
increment: (n) => state => ({ count: state.count + n }) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment