emattias
10/12/2017, 4:47 PMagartha
10/12/2017, 5:24 PMstate=undefined
to reset to initialState 😄benjie
10/12/2017, 7:21 PMconst initialState = {};
class Foo extends React.Component {
state = initialState;
reset() {
this.setState(initialState);
}
...
}
benjie
10/12/2017, 7:22 PMbenjie
10/12/2017, 7:22 PMreplaceState
API but I think it’s removed or deprecated.kimf
10/13/2017, 4:29 AMthis.setState(() => {})
But maybe it might be a anti-pattern to add new keys to state inside your component(s).kimf
10/13/2017, 4:29 AMhvdklauw
10/13/2017, 7:00 AMbenjie
10/13/2017, 8:22 AMthis.setState(Object.assign(mapKeys(this.state, () => undefined), this.initialState))