Skip to content

fixing async loader for v3 - #952

Merged
prateekbh merged 2 commits into
masterfrom
hydrationfix
Jan 27, 2020
Merged

fixing async loader for v3#952
prateekbh merged 2 commits into
masterfrom
hydrationfix

Conversation

@prateekbh

@prateekbh prateekbh commented Jan 25, 2020

Copy link
Copy Markdown
Member

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 ForsakenHarmony and developit and removed request for developit January 25, 2020 17:03
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

@developit

developit commented Jan 27, 2020

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

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

@ForsakenHarmony

Copy link
Copy Markdown
Member

Does this handle route transitions as well now?

@developit

Copy link
Copy Markdown
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