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

ReactWrapper.instance() documentation seems to be wrong/outdated #1669

Closed
conor-cafferkey-sociomantic opened this issue May 31, 2018 · 3 comments

Comments

@conor-cafferkey-sociomantic
Copy link
Contributor

Describe the bug
The documentation for ReactWrapper.instance() is seems to be wrong/outdated:

Returns the instance of the root component.

and:

Gets the instance of the component being rendered as the root node passed into mount().

NOTE: can only be called on a wrapper instance that is also the root instance.

As of Enzyme 3, ReactWrapper.instance() can be called at any level of the tree, or rather instance() does what getNode() used to.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the Full Rendering docs
  2. Scroll down to .instance() (note outdated description)
  3. Navigate to the .instance() doc page (note outdated content)

Expected behavior
Should describe the new behavior since Enzyme 3:

enzyme now allows for you to grab the instance() of a wrapper at any level of the render tree, not just at the root. This means that you can .find(...) a specific component, then grab its instance and call .setState(...) or any other methods on the instance that you'd like.

For mount wrappers, the .getNode() method used to return the actual component instance. This method no longer exists, but .instance() is functionally equivalent to what .getNode() used to be.

Reference:

@ljharb
Copy link
Member

ljharb commented May 31, 2018

Thanks, could you submit a PR with the corrections you have in mind?

@conor-cafferkey-sociomantic
Copy link
Contributor Author

Sure! On a related note: should the docs for getNode()/getNodes() be removed? It seems that support for those was removed completely in 3.3.0.

conor-cafferkey-sociomantic added a commit to conor-cafferkey-sociomantic/enzyme that referenced this issue Jun 1, 2018
conor-cafferkey-sociomantic added a commit to conor-cafferkey-sociomantic/enzyme that referenced this issue Jun 1, 2018
@ljharb
Copy link
Member

ljharb commented Jun 29, 2018

@conor-cafferkey-sociomantic the commit you linked is part of all v3 releases, not just 3.3.0. I think it's a good idea to remove the docs for those methods.

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

No branches or pull requests

2 participants