Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

event.persist()

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

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;
      })
    ))
  };
Comment

PREVIOUS NEXT
Code Example
Javascript :: js add item to array 
Javascript :: yarn add next auth 
Javascript :: redirect to website from promise value fetch 
Javascript :: how to redirect react router from the app components 
Javascript :: kick commands discord.js 
Javascript :: toggle text on click in angular 
Javascript :: named regex group JS 
Javascript :: biggest number javascript 
Javascript :: change inside div with jquery 
Javascript :: disable other options in select except the selected 
Javascript :: uppercase first letter javascript 
Javascript :: closures in javascript 
Javascript :: javascript insert div into another div 
Javascript :: generate express app 
Javascript :: chrome storage set example 
Javascript :: jquery get text of element without child elements 
Javascript :: cors error in node js express 
Javascript :: convert date to unix timestamp javascript 
Javascript :: make property read-only javascript 
Javascript :: pause javascript 
Javascript :: spring react 
Javascript :: find an object from array of objects javascript 
Javascript :: 1 dollar in rupees 
Javascript :: Check if an array contains a object in javascript 
Javascript :: show and hide div based on radio button click react 
Javascript :: javascript add days 
Javascript :: next js custom document 
Javascript :: axios data fetch 
Javascript :: Como saber se existe um atributo em um objeto 
Javascript :: data table is not a function in vue 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =