react 使用 ref 报错 ,[eslint] Using string literals in ref attributes is deprecated. (react/no-string-refs)
报错1: var Hello = createReactClass({ componentDidMount: function() { var component = this.refs.test; }, render: function() { return <div ref="test">ref, test.</div>; } }); 正确: var Hello = createReactClass({ 2 componentDidMount: function() { 3 var component = this.test; 4 5 }, 6 render() { 7 return <div ref={(c) => { this.test = c; }}>test, ref.</div>; 8 } 9 });