Skip to content

Commit

Permalink
[Docs] mount: ref: Update docs to be consistent with v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Golab authored and ljharb committed Oct 9, 2017
1 parent 5be7999 commit 4553bb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions docs/api/ReactWrapper/ref.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `.ref(refName) => ReactWrapper`
# `.ref(refName) => ReactComponent | HTMLElement`

Returns a wrapper of the node that matches the provided reference name.
Returns the node that matches the provided reference name.


NOTE: can only be called on a wrapper instance that is also the root instance.
Expand All @@ -12,7 +12,7 @@ NOTE: can only be called on a wrapper instance that is also the root instance.

#### Returns

`ReactWrapper`: A wrapper of the node that matches the provided reference name.
`ReactComponent | HTMLElement`: The node that matches the provided reference name. This can be a react component instance, or an HTML element instance.



Expand All @@ -35,8 +35,7 @@ class Foo extends React.Component {

```jsx
const wrapper = mount(<Foo />);
expect(wrapper.ref('secondRef').prop('amount')).to.equal(4);
expect(wrapper.ref('secondRef').text()).to.equal('Second');
expect(wrapper.ref('secondRef').innerText).to.equal('Second');
```


Expand Down
6 changes: 3 additions & 3 deletions packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ class ReactWrapper {
}

/**
* If the root component contained a ref, you can access it here
* and get a wrapper around it.
* If the root component contained a ref, you can access it here and get the relevant
* react component instance or HTML element instance.
*
* NOTE: can only be called on a wrapper instance that is also the root instance.
*
* @param {String} refname
* @returns {ReactWrapper}
* @returns {ReactComponent | HTMLElement}
*/
ref(refname) {
if (this[ROOT] !== this) {
Expand Down

0 comments on commit 4553bb7

Please sign in to comment.