Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Using async in UseEffect

useEffect(() => {
  const getUsers = async () => {
    const users = await fetchUsers();
    setUsers(users);
  };

  getUsers(); // run it, run it

  return () => {
    // this now gets called when the component unmounts
  };
}, []);
Source by ultimatecourses.com #
 
PREVIOUS NEXT
Tagged: #Using #async #UseEffect
ADD COMMENT
Topic
Name
7+6 =