Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

.push( ) is not updating the variable

const handlePress=(day)=>{
   setData(day); //`day` is set here but not applied immediately
   setName(`${events[rand]}`)
   datas.push(data); //data is the previous data, not `day`
   console.log(datas);
 }
 
PREVIOUS NEXT
Tagged: #updating #variable
ADD COMMENT
Topic
Name
4+6 =