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

[BREAKING] Add .root() and make shallow() and mount() semantics consistent #1107

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lelandrichardson
Copy link
Collaborator

to: @ljharb

This PR updates both mount() and shallow() to have similar semantics with respect to what the wrapper that is returned by them.

The idea is that mount(<Foo />) and shallow(<Foo />) both return a wrapper that's around the node that Foo rendered, and not <Foo /> itself. This means that calling .type() and .instance() on the resulting wrapper will not return Foo and an instance of Foo, but the type and instance of the root node returned by it's render function.

Additionally, calling .root() on the wrapper will return a new wrapper that is around the node of <Foo />. Calling .type() on this wrapper will return Foo and .instance() will return the Foo component instance.

This is a huge breaking change, and i'm not convinced that this is the right API. But putting up this PR for comments.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Let's chat more about this API and alternatives; but tbh I think this looks great.

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