Next.js Discord

Discord Forum

Page flashing on router.refresh()

Answered
American posted this in #help-forum
Open in Discord
AmericanOP
Hello!

I'm running a router.refresh on a time on a certain page to fake "live updates". It works well except the page is "flashing" every time it runs. It's not every single component either.

What can be the cause of this? Not sure where to start debugging this
Answered by Arinji
In build it wont flash @American
View full answer

5 Replies

AmericanOP
Sorry, like this:

const router = useRouter();
useEffect(() => {
  if (!task) {
    return;
  }
  const interval = setInterval(() => {
    router.refresh();
  }, 1000);

  return () => clearInterval(interval);
}, [task]);
are you on dev mode?
In build it wont flash @American
Answer
AmericanOP
@Arinji oh nice, thank you. Just tested it and you are correct. I was on dev