using useeffect for asynchronous function code example
Example 1: useeffect async await
const getUsers = async () => {
const users = await axios.get('https://randomuser.me/api/?page=1&results=10&nat=us');
setUsers(users.data.results);
};
useEffect(() => {
getUsers();
}, []);
Example 2: async useeffect
useEffect(() => {
(async function anyNameFunction() {await loadContent();})();
}, []);