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

allow nested act()s from different renderers #15816

Closed

Conversation

threepointone
Copy link
Contributor

@threepointone threepointone commented Jun 4, 2019

Sometimes apps can be tested with multiple renderers at once. Examples -

  • react-art being used inside react-dom. This was 'fixed' by disabling missing act warnings for embedded renders don't fire missing act() warnings for react-art #15975
  • ReactDOM.render being used inside another component tree. The parent component will be rendered using ReactTestRenderer.create for a snapshot test or something.
  • a ReactDOM instance interacting with a ReactTestRenderer instance (like for the new devtools)

This PR is for the other 2 usecases. It replaces the sigil reference with a stack that holds all sigils as act scopes open/close, and compares against the stack for when to show the missing act() warning.

Open question - At what point should flushPassiveEffects be called? On exiting the last act of any type? Or for a given type?

@sizebot
Copy link

sizebot commented Jun 4, 2019

No significant bundle size changes to report.

Generated by 🚫 dangerJS

@threepointone
Copy link
Contributor Author

threepointone commented Jun 4, 2019

[outdated]

@acdlite acdlite mentioned this pull request Jun 4, 2019
9 tasks
Copy link
Collaborator

@acdlite acdlite left a comment

Choose a reason for hiding this comment

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

I don't really like this solution, but rather than bikeshedding it, I would prefer if we first land a PR that forces Suspense fallbacks to commit at the end of act, because that will likely involve architectural changes that affect how we implement this PR.

*/

const ReactCurrentActingRendererSigil = {
current: (null: null | (() => boolean)),
current: ([]: Array<{}>),
Copy link
Collaborator

@acdlite acdlite Jun 11, 2019

Choose a reason for hiding this comment

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

This is conceptually a Set, not an Array, so (assuming this is the approach we go with) let's make it an Set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I started this with a Set, until I realized it's not one. It's a stack. Consider when leaving an act() scope, if it was a Set, how could I know if the sigil has to be removed from the set?

@threepointone threepointone changed the title RFC - allow nested act()s from different renderers allow nested act()s from different renderers Jun 28, 2019
@threepointone
Copy link
Contributor Author

Open question - At what point should flushPassiveEffects be called? On exiting the last act of any type? Or for a given type?

sometimes apps can be made wtih multiple renderers. a specific usecase is react-art embedded inside react-dom. in these cases, we want to be able to wrap an update with acts corrsponding to both the renderers. In this PR, we change ReactCurrentActingRendererSigil to hold a stack of sigils (instead of just the current active one), pushing and popping onto it as required.

This commit also fixes the dom fixtures tests, which were broken? ugh.
@threepointone
Copy link
Contributor Author

abandoning this for #16039

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

Successfully merging this pull request may close these issues.

None yet

4 participants