ndresx / react-countdown

A customizable countdown component for React.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning: Text content did not match. Server: "33" Client: "30"

mthcalixto opened this issue · comments

Help-me, console error about countdown using Next.js

Console Error:
Screenshot_40

Client:
Screenshot_41

Code:
Screenshot_42

Hi, does this help #101 (comment)?

Hi, does this help #101 (comment)?

It only works if I add in each item in the list.

<li suppressHydrationWarning>
	{zeroPad(days)} <span>Days</span>
</li>
<li suppressHydrationWarning>
	{zeroPad(hours)} <span>Hours</span>
</li>
<li suppressHydrationWarning>
	{zeroPad(minutes)} <span>Minutes</span>
</li>
<li suppressHydrationWarning>
	{zeroPad(seconds)} <span>Seconds</span>
</li>

Is there another way?

Hmm, I don't think so, to be honest (I don't know). Maybe it works if you set autoplay to false and start it manually in the client.

For what it's worth, what helped me was adding a 'isLoaded' state variable and then setting it to true in UseEffect(). Then show countdown based on that.

  const [ isLoaded, setIsLoaded] = useState(false)

  ...

  useEffect(() => {
    setIsLoaded(true)
  }, [])

  ...

  { isLoaded &&
    <Countdown .../>
  }