Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix client-side relative time calculation for statically generated routes .. #520

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

Jash2606
Copy link
Contributor

@Jash2606 Jash2606 commented Oct 3, 2024

Fix #422

Issue:

The RelativeTime component displayed incorrect relative time when rendered on statically generated routes since it was computed server-side and did not update based on the client's time.

Solution:

  • Refactored the RelativeTime component to compute the relative time on the client side.
  • Added the "use client" directive to ensure that the component runs entirely on the client side.
  • Implemented useEffect and useState to calculate and update relative time every minute dynamically.
  • Ensured the text representation of relative time is accurate on client-side rendering, fixing the issue of stale time displays on static pages.

This update addresses the problem by making the relative time always reflect the current time on the client side, providing an accurate user experience.

Copy link

netlify bot commented Oct 3, 2024

Deploy Preview for leaderboard-develop ready!

Name Link
🔨 Latest commit e0abf9d
🔍 Latest deploy log https://app.netlify.com/sites/leaderboard-develop/deploys/66fe8b72994f6a0009089a4f
😎 Deploy Preview https://deploy-preview-520--leaderboard-develop.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rithviknishad rithviknishad merged commit bfd14ee into ohcnetwork:main Oct 3, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure RelativeTime component's text representation is client side computed
2 participants