Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

use state value change right after setState or state update

setMovies(result);
console.log(movies) // movies here will not be updated

so do it in useEffect

useEffect(() => {
    // action on update of movies
}, [movies]);

https://www.google.com/search?q=can+i+use+state+value+in+function+immediately+after+setting+it&oq=can+i+use+state+value+in+function+immediately+after+setting+it&aqs=chrome..69i57j69i64.10511j0j7&sourceid=chrome&ie=UTF-8
 
PREVIOUS NEXT
Tagged: #state #change #setState #state #update
ADD COMMENT
Topic
Name
5+8 =