What i have to do ?
Either one of the two things the error says, or just remove the function and put the logic that's in it directly into your useEffect
callback, if you only ever use it from that callback.
Here's what the two options the error message gave you look like: Moving the loadAllAbout
function into your useEffect
callback:
useEffect(() => {
// ...code using `loadAllAbout` (here or after it, either is fine)...
function loadAllAbout() {
// ...
}
}, []);
Or using useCallback
or similar to make loadAllAbout
not a new function every time your component function runs:
const loadAllAbout = useCallback(() => {
// ...
}, []);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…