Skip to content

Commit

Permalink
Update ref docs to be consistent with version 3
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 baefd2c commit 1dec400
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 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`

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`: The node that matches the provided reference name.



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
4 changes: 2 additions & 2 deletions packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ class ReactWrapper {

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

0 comments on commit 1dec400

Please sign in to comment.