问题
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