简体   繁体   中英

How to add event listener to redux form

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>
<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?")
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM