Answers for "why to use event.persist"

0

event.persist()

handleClick(event) {
        event.persist();
        this.setState((prevState) => ({
            foo: prevState.foo + event.pageX
        }));
    }
Posted by: Guest on April-26-2020
1

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;
      })
    ))
  };
Posted by: Guest on May-13-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language