Skip to content

Commit 4553bb7

Browse files
Adam Golabljharb
authored andcommitted
[Docs] mount: ref: Update docs to be consistent with v3
1 parent 5be7999 commit 4553bb7

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

docs/api/ReactWrapper/ref.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# `.ref(refName) => ReactWrapper`
1+
# `.ref(refName) => ReactComponent | HTMLElement`
22

3-
Returns a wrapper of the node that matches the provided reference name.
3+
Returns the node that matches the provided reference name.
44

55

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

1313
#### Returns
1414

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

1717

1818

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

3636
```jsx
3737
const wrapper = mount(<Foo />);
38-
expect(wrapper.ref('secondRef').prop('amount')).to.equal(4);
39-
expect(wrapper.ref('secondRef').text()).to.equal('Second');
38+
expect(wrapper.ref('secondRef').innerText).to.equal('Second');
4039
```
4140

4241

packages/enzyme/src/ReactWrapper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ class ReactWrapper {
176176
}
177177

178178
/**
179-
* If the root component contained a ref, you can access it here
180-
* and get a wrapper around it.
179+
* If the root component contained a ref, you can access it here and get the relevant
180+
* react component instance or HTML element instance.
181181
*
182182
* NOTE: can only be called on a wrapper instance that is also the root instance.
183183
*
184184
* @param {String} refname
185-
* @returns {ReactWrapper}
185+
* @returns {ReactComponent | HTMLElement}
186186
*/
187187
ref(refname) {
188188
if (this[ROOT] !== this) {

0 commit comments

Comments
 (0)