Skip to content

Commit

Permalink
Added examples and related methods to the .ref(refName) documentation…
Browse files Browse the repository at this point in the history
… page
  • Loading branch information
marlonbernardes committed Dec 20, 2015
1 parent 5f0d7ca commit aec014e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions docs/api/ReactWrapper/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,30 @@ NOTE: can only be called on a wrapper instance that is also the root instance.



#### Example
#### Examples

```jsx
class Foo extends React.Component {
render() {
return (
<div>
<span ref="firstRef" amount={2}>First</span>
<span ref="secondRef" amount={4}>Second</span>
<span ref="thirdRef" amount={8}>Third</span>
</div>
);
}
}
```

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


#### Related Methods

- [`.props() => Object`](props.md)
- [`.state([key]) => Any`](state.md)
- [`.find(selector) => ReactWrapper`](find.md)
- [`.findWhere(predicate) => ReactWrapper`](findWhere.md)

0 comments on commit aec014e

Please sign in to comment.