This repository was archived by the owner on Jan 24, 2025. It is now read-only.
Allow to override the playground's editor's code #906
Closed
+9
−4
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.
Description
Currently the code that gets displayed in the playground's editor is the same as the one passed to the playground as its children. But because of issue #904, I had to be able to pass a simple component to the playground, while still showing the actual code of that component in the playground's editor.
This PR allows to pass an additional prop to the
Playground
component, callededitorCode
, which is the actual code (as a string) that will be shown in the editor, regardless of the code passed to the playground as its children.For example :
But doing so makes the playground's editor only show
<Example />
, which forces the user to open theExamples.tsx
file to actually see the code used.With this PR, I can do the following and have the expected result :
Edit : This PR revealed an expected but undesirable effect of the playground for my use cases, which I described and fixed in #907.