- ref:react对真实dom的引用
- ref在reactElement上
<div ref={(ref) => { this.div = ref; }}>
console.log(this.button)
> 真实的DOM
- ref在react组件上
<Button
ref={(ref) => { this.button = ref; }}
key={this.state.list}
size='long'
btnType='primary'
isRadius={false}
>{this.state.list}</Button>
console.log(this.button)
> Button {props: Object, context: Object, refs: Object, updater: Object, _reactInternalInstance: ReactCompositeComponentWrapper…}
//拿到的不是真实dom而是组件实例
//需要用ReactDom.findDOMNode来拿到真实DOM
ReactDom.findDOMNode(this.button)