Initiate internal Date with a static value#69
Open
apostolos wants to merge 1 commit intodate-fns:mainfrom
Open
Initiate internal Date with a static value#69apostolos wants to merge 1 commit intodate-fns:mainfrom
apostolos wants to merge 1 commit intodate-fns:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR modifies the constructor of
TZDateMinito create the internalDatewith a static value.In frameworks like Next.js which monitors the use of "dynamic APIs", passing static arguments to the
TZDateorTZDateMiniconstructors 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()) orRequest data (e.g.
cookies(),headers(),connection(), andsearchParams).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.