Skip to content

Fixed Hydration Error from Clock due to Mismatched Server and Client HTML

Chris Yang requested to merge chris/73-fix-clock-hydration into main

Fixes this bug: image

The above is caused by calling Date() on the server when the variable is declared, which causes a mismatch between the timestamps by the time it gets to the client. The HTML can only be modified once it gets to the client, so the state must be empty until useEffect() runs.

Merge request reports

Loading