Skip to content

Commit cb7cb65

Browse files
committed
fix demo07
1 parent 7f66384 commit cb7cb65

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,12 @@ ReactDOM.render(
217217

218218
## Demo07: Finding a DOM node ([source](https://github.com/ruanyf/react-demos/blob/master/demo07/index.html))
219219

220-
Sometimes you need to reference a DOM node in a component. React gives you `ReactDOM.findDOMNode()` to find it.
220+
Sometimes you need to reference a DOM node in a component. React gives you the `ref` attribute to find it.
221221

222222
```js
223223
var MyComponent = React.createClass({
224224
handleClick: function() {
225-
ReactDOM.findDOMNode(this.refs.myTextInput).focus();
225+
this.refs.myTextInput.focus();
226226
},
227227
render: function() {
228228
return (
@@ -240,7 +240,7 @@ ReactDOM.render(
240240
);
241241
```
242242

243-
The desired DOM node should have a `ref` attribute, and `ReactDOM.findDOMNode(this.refs.[refName])` would return the corresponding DOM node. Please be minded that you could do that only after this component has been mounted into the DOM, otherwise you get `null`.
243+
The desired DOM node should have a `ref` attribute, and `this.refs.[refName]` would return the corresponding DOM node. Please be minded that you could do that only after this component has been mounted into the DOM, otherwise you get `null`.
244244

245245
## Demo08: this.state ([source](https://github.com/ruanyf/react-demos/blob/master/demo08/index.html))
246246

demo07/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<script type="text/babel">
1111
var MyComponent = React.createClass({
1212
handleClick: function() {
13-
ReactDOM.findDOMNode(this.refs.myTextInput).focus();
13+
this.refs.myTextInput.focus();
1414
},
1515
render: function() {
1616
return (

0 commit comments

Comments
 (0)