fix(website): prevent playground formatted editor from being empty on navigation #699
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.
What changed with this PR:
Website's playground no longer displays an empty formatted (read-only) editor when navigating to another page and then back to the playground.
There seems to be a bug in Monaco Editor for React where in certain situations, updating its value prop immediately after rendering the component for the first time causes it to continue rendering the original value. I verified that the component was being passed the formatted code as its value 2nd, after initially setting it to empty, and yet it was rendering empty.
This fix works around that apparent bug by no longer rendering the component at all on the initial render, meaning it will only render the formatted (read-only) editor after Prettier formats it.