-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRefs.js
More file actions
30 lines (28 loc) · 760 Bytes
/
Refs.js
File metadata and controls
30 lines (28 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React, { Component } from 'react'
class Refs extends Component {
constructor(props) {
super(props)
this.inref=React.createRef()
this.callbackref=null
this.Callback=(element)=>{
this.callbackref=element
}
}
componentDidMount(){
// this.inref.current.focus()
this.callbackref.focus()
}
buttonhandle=()=>{
alert(this.inref.current.value)
}
render() {
return (
<div>
<input type="text" ref={this.inref}/>
<input type="text" ref={this.Callback}/>
<button onClick={this.buttonhandle}>Hiii</button>
</div>
)
}
}
export default Refs