node => input = node
es6箭头函数倒是经常用,搞不清为啥最后还来个赋值
render() {
let input = '';
return (
<div>
<input ref={node => input = node} />
<button type="submit" onClick={() => {
console.log(input.value);
}}>添加</button>
</div>
);
}
简洁写法,相当于
xxx => {let xx = xxx; return xx;}