e.persist() code example
Example 1: react supported events
onClick
onContextMenu
onDoubleClick
onDrag
onDragEnd
onDragEnter
onDragExit
onDragLeave
onDragOver
onDragStart
onDrop
onMouseDown
onMouseEnter
onMouseLeave
onMouseMove
onMouseOut
onMouseOver
onMouseUp
Example 2: event.persist()
handleClick(event) {
event.persist();
this.setState((prevState) => ({
foo: prevState.foo + event.pageX
}));
}
Example 3: why to use event.persist
const handleFilterChange = (event) => {
event.persist();
setFilters(currentFilters => (
produce(currentFilters, draftFilter => {
draftFilter[event.target.name] = event.target.value;
})
))
};