Skip to content

Instantly share code, notes, and snippets.

@kabbi
Created January 21, 2017 15:53
Show Gist options
  • Save kabbi/26409b7d818562ddce5c63996709d41f to your computer and use it in GitHub Desktop.
Save kabbi/26409b7d818562ddce5c63996709d41f to your computer and use it in GitHub Desktop.
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