Skip to content

Instantly share code, notes, and snippets.

@Godefroy
Created March 1, 2020 17:15
Show Gist options
  • Save Godefroy/54ae0378a57919f02ec6fa519f4fc05b to your computer and use it in GitHub Desktop.
Save Godefroy/54ae0378a57919f02ec6fa519f4fc05b to your computer and use it in GitHub Desktop.
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