event.persist()
handleClick(event) {
event.persist();
this.setState((prevState) => ({
foo: prevState.foo + event.pageX
}));
}
event.persist()
handleClick(event) {
event.persist();
this.setState((prevState) => ({
foo: prevState.foo + event.pageX
}));
}
why to use event.persist
//Without event.persist() ,
//React will make the first event value as null when second event is fired.
//How to use?
const handleFilterChange = (event) => {
event.persist();
setFilters(currentFilters => (
produce(currentFilters, draftFilter => {
draftFilter[event.target.name] = event.target.value;
})
))
};
react supported events
onClick
onContextMenu
onDoubleClick
onDrag
onDragEnd
onDragEnter
onDragExit
onDragLeave
onDragOver
onDragStart
onDrop
onMouseDown
onMouseEnter
onMouseLeave
onMouseMove
onMouseOut
onMouseOver
onMouseUp
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us