feat: Define Components at beginning and end of body #185
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.
Adds 2 options to
playroom.config.js
, which arebodyStart
andbodyEnd
. They work similarly toframeComponent
, which means that they receive a file path to a component which will be rendered at the beginning/end of body (well in fact in the root div).Example usage:
This was necessary for my team as we wanted to plug an Analytics library on our playroom, which of course requires us to add a script in the
<body />
. It could also be used to provide a watermark, link or anything absolutely positioned on the page, maybe for branding purposes. Furthermore, I think this could also fix issue #40, as using the newbodyStart
option and a library such as React Helmet, this use case could be covered.I am also aware that some things are missing from this PR such as examples and documentation, which I will include once I know this is relevant to this repo.
Also, I am considering adding a similar feature to the preview page, so we can have analytics there too. Prop names could be something like
previewBodyStart
andpreviewBodyEnd
.