how call async function inside useEffect code example
Example 1: react useeffect async
const MyFunctionnalComponent: React.FC = props => {
useEffect(() => {
// Using an IIFE
(async function anyNameFunction() {
await loadContent();
})();
}, []);
return <div></div>;
};
Example 2: async useeffect
useEffect(() => {
(async function anyNameFunction() {await loadContent();})();
}, []);