-
Notifications
You must be signed in to change notification settings - Fork 660
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
Adds support for synchronously updated tags (Closes #291) #297
Conversation
Codecov Report
@@ Coverage Diff @@
## master #297 +/- ##
==========================================
+ Coverage 98.94% 98.96% +0.02%
==========================================
Files 3 3
Lines 285 291 +6
==========================================
+ Hits 282 288 +6
Misses 3 3
Continue to review full report at Codecov.
|
d0943b0
to
0f1cbdb
Compare
test/HelmetDeclarativeTest.js
Outdated
it("executes synchronously when defer={true} and async otherwise", done => { | ||
ReactDOM.render( | ||
<Helmet> | ||
<script defer={false}> |
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.
defer
is (I believe) specific to the <script>
tag. So this solution wouldn't work for style or any other tag. Perhaps it makes more sense to bubble up the attribute to the <Helmet>
wrapper? That would give devs the flexibility to sync-render the entire Helmet instance, rather than the individual tag.
<Helmet defer={false}>
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.
Option 2 would be to keep this syntax, but strip out invalid defer
attributes before we write to the DOM.
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.
Good point. Maybe it should just go to <Helmet>
, then the user can decide whether to separate tags into the defer
<Helmet>
or not. Would make the API easier to support as well.
I'll redo the PR today.
… sync or deferred. Default is defer={true}. Closes nfl#291
@doctyper Update the PR so that <div>
<Helmet defer={false}>
{/* sync tags... */}
</Helmet>
<Helmet>
{/* async tags... */}
</Helmet>
</div> |
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.
Great PR, thanks!
Hey! Do you have any plans to merge it? |
@cwelch5 could you please publish new npm version with merged changes? 🙏 |
delete window.__spy__; | ||
}); | ||
|
||
it("executes synchronously when defer={true} and async otherwise", done => { |
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.
shouldn't this be executes synchronously when defer={false}
instead?
This PR is to address the issue with FOUC as outlined in #291.
The code changes involve splitting the updates into two groups: deferred (default), and sync. The sync behaviour is opt-in using the new
defer={false}
prop onHelmet
.Two new tests have been added to both declarative and original API. They both test that updates can happen before
requestIdleCallback
and during.