event persist react 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: 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;
      })
    ))
  };

Tags:

Html Example