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.
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
Feat: error-decoder #6214
Feat: error-decoder #6214
Changes from 6 commits
c676424
c40b546
1927c29
31f6646
550c430
4c89c2b
9b53ec0
6fd9331
90586e4
ef1158b
4383ac9
b6b0bdb
f2d8160
b416530
29f4eaa
45e472c
759bd2c
b22d684
b3f3be7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rickhanlonii
Note that although the page will be SSG-ed at the build time, the
router.query
still requires client-side rendering and will only be populated after the initial hydration, thusisReady
can not be avoided.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the query changes, won't that trigger an update? Why is the
isReady
needed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only when
isReady
istrue
cabPer Next.js documentation,: https://nextjs.org/docs/pages/building-your-application/rendering/automatic-static-optimization#how-it-works
This also prevents SSR hydration mismatch errors. On the server, Next.js SSR the page without the
query
, and Next.js will also use the empty query object during the initial hydration.The
isReady: true
will only be set after the initial hydration has finished and thequery
object has been populated (theisReady
here acts similarly with React's two-pass rendering approach).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok that's a bummer. I also see that there are multiple updates that happen before
query
andisReady
are set, delaying the time it takes to render the final message.Instead, why don't we read the query params ourselves instead of from the router. That will allow us to set the message in an effect, which fires immediately after hydration, and that will set it at the first moment possible.
Finally, we can add a fade in animation to avoid the flash of unparsed args. Something like this:
Here's what the animation looks like:
Screen.Recording.2023-08-18.at.2.58.40.PM.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rickhanlonii Done in
4383ac9
(#6214)Note that, inside
useEffect
I add an early return if theerrorMessages
doesn't contain%s
. This should avoid extra re-renders for most of the errors.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rickhanlonii Would you like to review the change in
4383ac9
(#6214)?In the meantime, I am going to start addressing
<ErrorDecoder>
for MDX you have mentioned.