(转)react 使用 ref 报错 ,[eslint] Using string literals in ref attributes is deprecated. (react/no-string-refs)
原文地址:https://www.cnblogs.com/gangerdai/p/7396226.html
react 项目中给指定元素加事件,使用到 react 的 ref 属性,Eslink 报错 [eslint] Using string literals in ref attributes is deprecated. (react/no-string-refs)
常用方法:(会报错)

var Hello = createReactClass({
componentDidMount: function() {
var component = this.refs.hello;
// ...do something with component
},
render: function() {
return <div ref="hello">Hello, world.</div>;
}
});

正确方法:

1 var Hello = createReactClass({
2 componentDidMount: function() {
3 var component = this.hello;
4 // ...do something with component
5 },
6 render() {
7 return <div ref={(c) => { this.hello = c; }}>Hello, world.</div>;
8 }
9 });

(转)react 使用 ref 报错 ,[eslint] Using string literals in ref attributes is deprecated. (react/no-string-refs)的更多相关文章
- react 使用 ref 报错 ,[eslint] Using string literals in ref attributes is deprecated. (react/no-string-refs)
react 项目中给指定元素加事件,使用到 react 的 ref 属性,Eslink 报错 [eslint] Using string literals in ref attributes is d ...
- React Natived打包报错java.io.IOException: Could not delete path '...\android\support\v7'解决
问题详情 React Native打包apk时在第二次编译时候报错: java.io.IOException: Could not delete path 'D:\mycode\reactnative ...
- React Native 日常报错
在学习React.js 或 React Native 过程中,有时看着别人的框架或代码,但总是会出现错误,因为React或之中用到的一些包经常更新,有些代码或教程就显得过旧了. 一.日常报错 'con ...
- React Native 基础报错及解决方案记录
刚开始上手RN,碰到很多坑,记录一下.碰到问题多去看看github上面的issue! 启动命令react-native run-ios报错 1.:xcrun: error: unable to fin ...
- [报错]ios开发 failed to read file attributes for
下载第三方demo,运行报错: failed to read file attributes for https://stackoverflow.com/questions/46301270/fa ...
- 【spring mvc】后台API查询接口,get请求,后台Date字段接收前台String类型的时间,报错default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'createDate';
后台API查询接口,get请求,后台Date字段接收前台String类型的时间筛选条件 后台接口接收 使用的实体 而createDate字段在后台实体中是Date类型 报错信息: org.spring ...
- react native 环境报错
按照react native中文网的文档安装 1.brew 管理软件 2.node 在终端启动工程后就报下面这个错误 这个错误是在RN在第一次配置环境启动一个工程的时候 ,在这过程中下载的缓存文件不完 ...
- react创建项目报错unexpected end of json while parsing near xxx
报这个错,执行下面的命令,然后重新创建项目就可以. npm cache clean --force
- React报错之无法在未挂载的组件上执行React状态更新
正文从这开始~ 总览 为了解决"Warning: Can't perform a React state update on an unmounted component" ,可以 ...
随机推荐
- 【hdu5527】【2015ACM/ICPC亚洲区长春站 】Too Rich
题目链接: pid=5527">http://acm.hdu.edu.cn/showproblem.php?pid=5527 题意&题解: 感觉自己真是弱啊,自己想的贪心是错的 ...
- Swift入坑系列—集合类型
数组(Arrays) 字典(Dictionaries) 数组(Arrays) 在OC里面,NSArray和NSMutableArray这两个类可以存储任意类型的对象,并且不提供所返回对象的任何特别信息 ...
- Windows10终端优化方案:Ubuntu子系统+cmder+oh-my-zsh
原问地址:https://zhuanlan.zhihu.com/p/34152045 最近从MacBook换到了种草已久的Surface Book 2,而我的工作环境也自然要从macOS换到Windo ...
- 三大主流ETL工具选型 分类: H2_ORACLE 2013-08-23 11:17 426人阅读 评论(0) 收藏
ETL(extract, transform and load)产品乍看起来似乎并不起眼,单就此项技术本身而言,几乎也没什么特别深奥之处,但是在实际项目中,却常常在这个环节耗费太多的人力,而在后续的维 ...
- iOS --- UIColor中使用16进制选取颜色
iOS中的UIColor能够使用16进制来选取颜色. 预先定义例如以下: #define UIColorFromHex(s) [UIColor colorWithRed:(((s & 0xFF ...
- 安装innotop
安装方法一: 下载地址:https://github.com/innotop/innotop yum install -y perl-TermReadKey yum install -y perl-D ...
- CVE-2014-3566
https://access.redhat.com/articles/1232123 https://tools.ietf.org/html/draft-ietf-tls-downgrade-scsv ...
- js匿名自执行函数
匿名自执行函数:没有方法名的函数闭包:闭包是指有权访问另一个函数作用域变量的函数: 通过一个实例来解释: 从网上找到了一个案例,使用了for循环.匿名自执行函数.setTimeout. 案例1: va ...
- thinkphp5如何使用ajax(变化的核心,也就是ajax作用的核心是什么)
thinkphp5如何使用ajax(变化的核心,也就是ajax作用的核心是什么) 一.总结 一句话总结:ajax的核心在于页面的不刷新而获取后台数据,所以后台的操作还是一样(获取参数,返回数据),只是 ...
- Methods and systems to control virtual machines
Methods and systems are provided to control the execution of a virtual machine (VM). A VM Monitor (V ...