useeffect when function is called code example
Example 1: how to have a function inside useeffect
useEffect(() => {
fetch(`https://jsonplaceholder.typicode.com/${query}`)
.then(response => response.json())
.then(json => setData(json));
}, [query]); // only re-run on query change
Example 2: React Hook "useEffect" is called in function
React component names need to start with a capital letter.
That's because React treats components starting with lowercase letters as DOM tags.
Therefore you should name it "Shoes"