dont call the useEffect untul props are there code example
Example 1: useeffect with cleanup
useEffect(() => {
//your code goes here
return () => {
//your cleanup code codes here
};
},[]);
Example 2: componentdidmount in hooks
useEffect(() => {
// Your code here
}, []);