How to add event listener to redux form Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to add event listener to redux form without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am trying to pass the keydown event to redux form but I am at a loss. Could some one please help me how to resolve this issue? Actually, I want to alert when user hit enter in redux form.

<div className="col-sm-3">
  <Field
    name={`${item}.value`}
    type="text"
    component={renderField}
    keyDown={() => alert("what ar eyou")}
    normalize={normalizeDropdown}
    label="Values"
  />
</div>

Answer

<Field
    name={`${item}.value`}
    type="text"
    component={renderField}
    onKeyDown={(e) => handleKeyDown(e)}
    normalize={normalizeDropdown}
    label="Values"
  />

const handleKeyDown = (e) => {
if(e.key == "Enter") {
alert("How are you?")
}
}
We are here to answer your question about How to add event listener to redux form - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji