use effect function in react js says to import while end’s up working fine


useEffect(() => {
  async function getTok() {
    await Gettestimon(); => console.log(;
    // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

hi i have a query really sorry if it is a old one or very well known one, but whenever i compile the highlighted code it says my function gettestimon which stands for get testimonial not something else, is not imported in effect’s but then it ends up working anyways i would like to know how to fic this, but i read somewhere and added

// eslint-disable-next-line react-hooks/exhaustive-deps i am really sorry if this has a common answer, i am a new developer and a learning one at that. i would appreciate any answers to the question

the exact error is

React Hook useEffect has a missing dependency: 'Gettestimon'. Either include it or remove the dependency array.eslintreact-hooks/exhaustive-deps

this is the website where it is used :-, thanks for reading, any and all answers are appreciated.


This is due to missing dependency.

useEffect method called for each render with the second argument is empty. But if you need your useEffect function to execute when only something changes we need to add that variable or object to dependency array.

In use Effect you used external objects out of function scope like alldoc, Gettestimon.

If you want to execute useEffect only with these object changes alldoc, Gettestimo, you need to add it in dependency array, otherwise you will send up in executing useEffect for each render cycle.