I would like to know how one can wire in a clear field via redux when using react. For instance, I have a form with some sample code.
<Field component={datewidget} id ="date" name="date" type="date" label="date" />
<button type="button"onClick={() => {(clearMyInput());}}>
</button>
The function clearMyInput is dispatched such that:
const mapDispatchToProps = (dispatch) => {
return {
clearMyInput: () => {
return dispatch(clearDate(datedata,value));
}
}
}
My question how can one clear the input field by simply clicking on the button and setting the value of the input to none.
For example in jquery, i can write something like this:
$("#button").click(function () {
$("#date").val("");
});
I would like to know how one can do this using redux forms in react.
refand clear it withrefs.myInput.value = '')clearDateaction. Normally (if you're using redux instead of local state) you'd bind a value in the store to the component viaconnect, then dispatch theclearMyInputaction. The reducer would respond by resetting that value in the store, and this would reset the value in the form....clearDate(datedata,value)- where are these values coming from? do you meanclearMyInput: (datedata,value) => {?