Dario
Dario

Reputation: 6280

Remove field from redux store

Is there a way to unset/remove a variable set with change method? In my code I programmatically set a field this way

this.props.change('extraBedChildrenNum', 1);

but I would like to unset this field so it is removed from the store. Any idea how to do this?

Upvotes: 1

Views: 738

Answers (2)

vijay
vijay

Reputation: 10997

From github issue

import {change} from 'redux-form';

dispatch(change('myForm', 'myField', 'newValue'))

this should help

Upvotes: 0

jakee
jakee

Reputation: 18556

There is not action creator to remove a field from a form provided to the decorated for component as a prop, but there is one exported by redux-form called unregisterField.

So you should be able to do something like this:

store.dispatch(unregisterField('MyFormName', 'extraBedChildrenNum'))

Hope this helps!

Upvotes: 1

Related Questions