Skip to content
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

fixing async loader for v3 #952

Merged
merged 2 commits into from
Jan 27, 2020
Merged

fixing async loader for v3 #952

merged 2 commits into from
Jan 27, 2020

Conversation

prateekbh
Copy link
Member

@prateekbh prateekbh commented Jan 25, 2020

TO BE MERGED after: preactjs/preact#2259

What kind of change does this PR introduce?
Bug fix

Did you add tests for your changes?
No

Summary

  • Fixes hydration in V3 for preactX

Does this PR introduce a breaking change?
No

@prateekbh prateekbh requested review from developit and ForsakenHarmony and removed request for developit January 25, 2020 17:03
@@ -48,7 +48,11 @@ if (typeof app === 'function') {
* to send other data like at some point in time.
*/
const CLI_DATA = { preRenderData };
root = render(h(app, { CLI_DATA }), document.body, root);
const doRender =
process.env.NODE_ENV !== 'production' || root.tagName !== 'script'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if we need to recommend folks use id="app" here. We could have L35 do:

let root = document.getElementById('preact_root') || document.body.firstElementChild;

Thoughts? It would help us avoid browser extensions potentially changing the value of firstElementChild on us.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! I really really want to do this. This stream lines everything for us

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally agree with it. :) Always wanted to do this one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@developit
Copy link
Member

developit commented Jan 27, 2020

Looks perfect aside from the one question about assuming firstElementChild. I think we can move forward with this regardless.

@prateekbh Only other thing would be if we want to consider having something for Preact 8? Or are we officially dropping support for it as of this PR?

@prateekbh
Copy link
Member Author

Only other thing would be if we want to consider having something for Preact 8

I guess lets keep it simple async-component v3 will be for cli v3 and async-component < v3 will be for CLI v1&2

@prateekbh prateekbh merged commit 754f041 into master Jan 27, 2020
@prateekbh prateekbh deleted the hydrationfix branch January 27, 2020 23:59
@developit
Copy link
Member

@prateekbh right, just currently CLI V3 supports Preact 8 and X at the same time.

@ForsakenHarmony
Copy link
Member

Does this handle route transitions as well now?

@developit
Copy link
Member

Ahh good point. This needs to only throw during hydration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants