Warning instead of error for 'new Date()' under dynamicIO #78646
Unanswered
filipjnc
asked this question in
App Router
Replies: 1 comment
-
I think, you can wrap the call to async function getNewDate() {
'use cache'
return new Date();
}
export default async function Home() {
const date = await getNewDate();
return (
<pre>{date.toISOString()}</pre>
);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Since [email protected] the build throws if it encounters routes with 'new Date()'. I read the docs and I generally agree reading time is ambiguous. But I also find the ergonomics of the reactive use case quite bad. Having to use useState + useEffect to just achieve a 'new Date()' feels convoluted.
Is this supposed to be the final solution or is the team working to improve the DX of the reactive use case? Cause if so, I'd suggest to keep it a warning during build.
Beta Was this translation helpful? Give feedback.
All reactions