Skip to content

Conversation

@BenoitZugmeyer
Copy link
Contributor

We have to define the class constructor, else async components are recreated everytime the parent rerenders.

Technical details: if not defined on the Async class, the property constructor is inherited from Component, and preact does not find the actual Async constructor in buildComponentFromVNode, so it doesn't find the component owner, so the component is recreated.

I made a gist if you want to reproduce 😄 https://gist.github.com/BenoitZugmeyer/67b44e172a44d013290d25b62052f207

We have to define the class `constructor`, else async components are
recreated everytime the parent rerenders.

Technical detail: if not defined on the `Async` class, the property
`constructor` is inherited from `Component`, and preact does not find
the actual `Async` constructor in `buildComponentFromVNode`, so it
doesn't find the component owner, so the component is recreated.
@developit
Copy link
Member

hah! I knew that would catch up with me. Thanks for the PR and great explanation.

@developit developit merged commit d52f19d into preactjs:master May 29, 2017
@BenoitZugmeyer BenoitZugmeyer deleted the fix-async-component branch May 30, 2017 18:56
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.

2 participants