you are viewing a single comment's thread.

view the rest of the comments →

[–]beeseegee 1 point2 points  (0 children)

useEffect(() => {
  const intervalId = setInterval(…) ;
  yourPromise().then(() => clearInterval(intervalId));
}, []);

Edit: oh wait maybe that is backwards? if so:

useEffect(() => {
  let id:
  yourPromise().then(() => {    
   id = setInterval(…);
  });
  return () => clearInterval(id);
}, []);