Skip to content

Commit dfdddfd

Browse files
sericaiagaearon
authored andcommitted
Update test-utils to use refs correctly (#215)
* Update test-utils to use refs correctly Update test-utils according to the new way of using refs: https://reactjs.org/docs/refs-and-the-dom.html * Tweak
1 parent 40de6b3 commit dfdddfd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

content/docs/addons-test-utils.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ Simulate an event dispatch on a DOM node with optional `eventData` event data.
6666
**Clicking an element**
6767

6868
```javascript
69-
// <button ref="button">...</button>
70-
const node = this.refs.button;
69+
// <button ref={(node) => this.button = node}>...</button>
70+
const node = this.button;
7171
ReactTestUtils.Simulate.click(node);
7272
```
7373

7474
**Changing the value of an input field and then pressing ENTER.**
7575

7676
```javascript
77-
// <input ref="input" />
78-
const node = this.refs.input;
77+
// <input ref={(node) => this.textInput = node} />
78+
const node = this.textInput;
7979
node.value = 'giraffe';
8080
ReactTestUtils.Simulate.change(node);
8181
ReactTestUtils.Simulate.keyDown(node, {key: "Enter", keyCode: 13, which: 13});

0 commit comments

Comments
 (0)