Created
January 21, 2017 15:53
-
-
Save kabbi/26409b7d818562ddce5c63996709d41f to your computer and use it in GitHub Desktop.
This file contains 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 { createStore } from 'redux'; | |
import { actions, combineForms } from 'react-redux-form'; | |
const store = createStore(combineForms({ | |
user: { | |
city: null, | |
}, | |
})); | |
console.log('Initial state:', store.getState()); | |
// User selected new city | |
store.dispatch(actions.change('user.city', { id: 42, title: 'London' })); | |
console.log('After change, still valid:', store.getState()); | |
// User resetted the form | |
store.dispatch(actions.reset('user')); | |
console.log('After reset, looks not quite the same as initial state:', store.getState()); | |
// What if we want to reset the field externally? It's already null, nothing bad could happen | |
store.dispatch(actions.change('user.city', null)); | |
console.log('After another change, city state is broken now:', store.getState()); | |
// This throws on my setup =( | |
store.dispatch(actions.resetValidity('user')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment