React 获取实际dom节点

1.ref
class AutoFocusInput extends Component {
componentDidMount () {
this.input.focus()
}

render () {
return (
this.input = input} />
)
}
}

ReactDOM.render(
,
document.getElementById('root')
)

2.ref

ref={(textarea) => this.textarea = textarea}
value={this.state.content}
onChange={this.handleContentChange.bind(this)} />

handleUsernameBlur (event) {
this._saveUsername(event.target.value)
}

你可能感兴趣的:(React 获取实际dom节点)