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

Detect React roots by checking the parent fiber #14681

Closed

Conversation

philipp-spiess
Copy link
Contributor

@philipp-spiess philipp-spiess commented Jan 23, 2019

Fixes #14535
Related to #13778
Alternative to #14682

As @gaearon already noted, we can not rely on a container node having a _reactRootContainer to detect a React Root since the createRoot() API will not set it.

Furthermore, the createRoot() API is currently only setting a property on the container in DEV mode.

We could:

  1. Set a property in prod as well. (Detect React roots created by createRoot #14682)
  2. Pass in more information into the appendChildToContainer() config.

This PR is an attempt to implement 2. to visualize the outcome. It feels bad to do this though since non of the other renderers need that property and I’m not sure how stable the reconciler API is (i.e if we can just add properties like this).

Fixes facebook#14535
Alternative to facebook#13778

As @gaearon already noted, we can not rely on a container node having a
`_reactRootContainer` to detect a React Root since the `createRoot()`
API will not set it.

Furthermore, the `createRoot()` API is currently only setting a property
on the container in DEV mode.

We could:

 1. Set a property in prod as well.
 2. Pass in more information into the `appendChildToContainer()` config.

This PR is an attempt to implement 2. to visualize the outcome. It feels
bad to do this though since non of the other renderers need that
property and I’m not sure how stable the reconciler API is (i.e if we
can just add properties like this).

Let me know if you prefer 1. or have another idea. 🙂
@philipp-spiess philipp-spiess changed the title Check the parent fiber in appendChildToContainer Detecting React roots by checking the parent fiber Jan 24, 2019
@aweary
Copy link
Contributor

aweary commented Jan 24, 2019

I think adding a property or some other approach would be better. Changing the reconciler API to account for a renderer-specific problem doesn't seem ideal.

@philipp-spiess
Copy link
Contributor Author

@aweary Yeah, I already thought so. Will do a second one.

philipp-spiess added a commit to philipp-spiess/react that referenced this pull request Jan 24, 2019
Fixes facebook#14535
Related to facebook#13778
Alternative to facebook#14681

As @gaearon already noted, we can not rely on a container node having a
`_reactRootContainer` to detect a React Root since the `createRoot()`
API will not set it.

Furthermore, the `createRoot()` API is currently only setting a property
on the container in DEV mode.

We could:

 1. Set a property in prod as well.
 2. Pass in more information into the `appendChildToContainer()` config.

This PR is an attempt to implement 1. It feels better than [the other
approach](facebook#14681) since we don't
need to change the reconciler API.
@philipp-spiess
Copy link
Contributor Author

philipp-spiess commented Jan 24, 2019

The other approach feels a lot less invasive: #14682. I'd say we continue there. Thanks for your input!

@philipp-spiess
Copy link
Contributor Author

Let's not rule this out completely just yet (see #14682 (comment)).

@philipp-spiess philipp-spiess changed the title Detecting React roots by checking the parent fiber Detect React roots by checking the parent fiber Jan 24, 2019
@stale
Copy link

stale bot commented Jan 10, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.

@stale stale bot added the Resolution: Stale Automatically closed due to inactivity label Jan 10, 2020
@stale
Copy link

stale bot commented Jan 17, 2020

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

@stale stale bot closed this Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Resolution: Stale Automatically closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Concurrent mode iOS hover behaviour
3 participants