fix: replace Date.now() with performance.now() in memo debug timing#6196
fix: replace Date.now() with performance.now() in memo debug timing#6196isaackaara wants to merge 1 commit intoTanStack:mainfrom
Conversation
Next.js warns about Date.now() usage in client components because it can cause hydration mismatches between server and client renders. While the Date.now() calls in memo() are only used for debug timing and guarded behind opts.debug, Next.js statically detects Date.now() usage and shows the warning regardless. Switching to performance.now() resolves the warning and provides more precise timing measurements for debug output. The performance.now() API is available in all modern browsers and Node.js 12+, which aligns with the project's engine requirements. Fixes TanStack#6127
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Next.js warns about
Date.now()usage in client components because it can cause hydration mismatches between server and client renders. While theDate.now()calls inmemo()are only used for debug timing and guarded behindopts.debug, Next.js statically detectsDate.now()usage and shows the warning regardless.Switching to
performance.now()resolves the Next.js warning and also provides more precise sub-millisecond timing measurements for debug output. Theperformance.now()API is available in all modern browsers and Node.js 12+, which aligns with the project's engine requirements.This is a debug-only change with no impact on runtime behavior.
Fixes #6127