码迷,mamicode.com
首页 > 其他好文 > 详细

ref 属性使用eslint报错

时间:2017-09-27 19:07:21      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:idm   logs   http   lint   efs   cti   mount   ted   pre   

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 });

 

ref 属性使用eslint报错

标签:idm   logs   http   lint   efs   cti   mount   ted   pre   

原文地址:http://www.cnblogs.com/weilantiankong/p/7603005.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!