Skip to content

Commit

Permalink
Updated docs for ReactWrapper.instance() enzymejs#1669
Browse files Browse the repository at this point in the history
  • Loading branch information
conor-cafferkey-sociomantic committed Jul 13, 2018
1 parent cd28cee commit fb19fda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
6 changes: 2 additions & 4 deletions docs/api/ReactWrapper/instance.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# `.instance() => ReactComponent`

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.
Returns the wrapper's underlying instance.



#### Returns

`ReactComponent`: The component instance.
`ReactComponent|DOMComponent`: The retrieved instance.



Expand Down
4 changes: 2 additions & 2 deletions docs/api/mount.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ Manually sets props of the root component.
#### [`.setContext(context) => ReactWrapper`](ReactWrapper/setContext.md)
Manually sets context of the root component.

#### [`.instance() => ReactComponent`](ReactWrapper/instance.md)
Returns the instance of the root component.
#### [`.instance() => ReactComponent|DOMComponent`](ReactWrapper/instance.md)
Returns the wrapper's underlying instance.

#### [`.unmount() => ReactWrapper`](ReactWrapper/unmount.md)
A method that un-mounts the component.
Expand Down
6 changes: 2 additions & 4 deletions packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,15 @@ class ReactWrapper {
}

/**
* 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.
* Returns the wrapper's underlying instance.
*
* Example:
* ```
* const wrapper = mount(<MyComponent />);
* const inst = wrapper.instance();
* expect(inst).to.be.instanceOf(MyComponent);
* ```
* @returns {ReactComponent}
* @returns {ReactComponent|DOMComponent}
*/
instance() {
if (this.length !== 1) {
Expand Down

0 comments on commit fb19fda

Please sign in to comment.