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