How to add event listener to redux form

▼魔方 西西 提交于 2020-07-22 04:30:37

问题


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>

回答1:


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


来源:https://stackoverflow.com/questions/62941948/how-to-add-event-listener-to-redux-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!