“Event.Persist ()” Respostas de código

Event.Persist ()

 handleClick(event) {
        event.persist();
        this.setState((prevState) => ({
            foo: prevState.foo + event.pageX
        }));
    }
Brave Badger

Por que usar o 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;
      })
    ))
  };
Rey

Procure respostas de código populares por idioma

Procurar outros idiomas de código