Fix student quotes mismatch quote urls #2647
Merged
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.
Fixes #2646.
The bug happens because we generate a random quote at
telescope/src/web/src/components/Banner.tsx
Line 108 in 323abdf
Because NextJS tries to pre-render stuff, first, a random quote is generated once at build time, and once when the page loads. Now the new quote is updated to the visual elements of the page but not the
href
of the<a>
tag which is still the pre-rendered one. I am not sure why thehref
is not updated.In this fix, I put the random quote to a state, and generate it once the banner component is loaded. I could also generate it in the
useState
initializer but the initializer might be invoked twice because of React development strict mode.Issue This PR Addresses
Type of Change
Description
Checklist