Skip to content

Initiate internal Date with a static value#69

Open
apostolos wants to merge 1 commit intodate-fns:mainfrom
apostolos:main
Open

Initiate internal Date with a static value#69
apostolos wants to merge 1 commit intodate-fns:mainfrom
apostolos:main

Conversation

@apostolos
Copy link
Copy Markdown

This PR modifies the constructor of TZDateMini to create the internal Date with a static value.

In frameworks like Next.js which monitors the use of "dynamic APIs", passing static arguments to the TZDate or TZDateMini constructors still result in rendering errors similar to the below:

Caution

Route "/some/path/page.tsx" used new Date() before accessing either uncached data (e.g. fetch()) or
Request data (e.g. cookies(), headers(), connection(), and searchParams).

Accessing the current time in a Server Component requires reading one of these data sources first.
Alternatively, consider moving this expression into a Client Component or Cache Component.
See more info here: https://nextjs.org/docs/messages/next-prerender-current-time

The simple change in this PR fixes the issue.

All tests are passing and there should be no differences in behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants