Skip to content

Commit bcee889

Browse files
authored
update 22 with createRef() approach
1 parent 2888021 commit bcee889

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,12 +754,16 @@
754754
755755
```javascript
756756
class MyComponent extends Component {
757+
constructor(props){
758+
super(props);
759+
this.node = createRef();
760+
}
757761
componentDidMount() {
758-
this.node.scrollIntoView()
762+
this.node.current.scrollIntoView();
759763
}
760764

761765
render() {
762-
return <div ref={node => this.node = node} />
766+
return <div ref={this.node} />
763767
}
764768
}
765769
```

0 commit comments

Comments
 (0)