Handling Event
【Handling Event】
1、React events are named using camelCase

2、You must call preventDefault explicitly to prevent default behaviour

3、define callback in class.
\
In JavaScript, class methods are not bound by default. If you forget to bind this.handleClick and pass it toonClick, this will be undefined when the function is actually called.
Generally, if you refer to a method without () after it, such as onClick={this.handleClick}, you should bind that method.
4、you can use an arrow function in the callback to ensure this pointer

This has performance problem. Do not use arrow function to solve the problem.
The problem with this syntax is that a different callback is created each time theLoggingButton renders. In most cases, this is fine. However, if this callback is passed as a prop to lower components, those components might do an extra re-rendering. We generally recommend binding in the constructor or using the property initializer syntax, to avoid this sort of performance problem.
参考:https://facebook.github.io/react/docs/handling-events.html
Handling Event的更多相关文章
- java event
What is an Event? Change in the state of an object is known as event i.e. event describes the change ...
- c# 关键字delegate、event(委托与事件)[MSDN原文摘录][1]
A delegate is a type that safely encapsulates a method, similar to a function pointer in C and C++. ...
- Adobe Scout 使用参考说明
Adobe Scout 用于优化 Flash 内容,是一款极为强大的工具,因为它能让您看到 Flash Player 幕后正在发生的事情.但是若明白 Flash Player 为什么做这些事情,您看到 ...
- YARN集群维护部分问题汇总
云梯开发人员在云梯Yarn集群的搭建和维护过程中做了许多工作,本文选择这期间部分较为典型的问题,通过对这些问题的分析和解决方案,为大家分享分布式系统问题调查的经验. 调查的问题 1. 2013年初引入 ...
- Windows api 函数全部列表 (未完成)
网上找了很久,发现没有完整版的,msdn上面有,但是不方便查阅,所以想自己整理一下:由于工程量过于庞大,希望大家共同完成.MSDN:http://msdn.microsoft.com/en-us/li ...
- jquery autocomplete ajax获取动态数据,兼容各浏览器,支持中文
jquery.autocomplete.js经过改动,支持各种浏览器.支持中文输入! 1.效果图例如以下 2.HTML和ajax代码 <!DOCTYPE html> <html xm ...
- FusionCharts for Flex的属性和事件
FusionCharts for Flex的属性和事件 1.Properties(属性) (1)FCChartType (2)FCDataURL (3)FCDataXML (4)FCDebugMode ...
- ABP EventBus(事件总线)
事件总线就是订阅/发布模式的一种实现 事件总线就是为了降低耦合 1.比如在winform中 到处都是事件 触发事件的对象 sender 事件的数据 e 事件的处理逻辑 方法体 通过E ...
- Hadoop YARN架构设计要点
YARN是开源项目Hadoop的一个资源管理系统,最初设计是为了解决Hadoop中MapReduce计算框架中的资源管理问题,但是现在它已经是一个更加通用的资源管理系统,可以把MapReduce计算框 ...
随机推荐
- Vue.js路由
有时候,我们在用vue的时候会有这样的需求,比如一个管理系统,点了左边的菜单栏,右边跳转到一个新的页面中,而且刷新的时候还会停留在原来打开的页面. 又或者,一个页面中几个不同的画面来回点击切换,这两种 ...
- couchdb安装
fabric涉及到了couchdb做为数据库,所以单独安装一个进行测试,当然也可以使用docker来安装. 项目地址:http://couchdb.apache.org/ 这里采用windows来安装 ...
- ROS 进阶学习笔记(12) - Communication with ROS through USART Serial Port
Communication with ROS through USART Serial Port We always need to communicate with ROS through seri ...
- shell执行class或jar
mc11>java -cp /home/ap/user/webproject/web.war/WEB-INF/lib/*:. com.userpackage.ExcelDemo 说明:/home ...
- hadoop动态添加删除节点datanode及恢复
1. 配置系统环境 主机名,ssh互信,环境变量等 本文略去jdk安装,请将datanode的jdk安装路径与/etc/hadoop/hadoop-evn.sh中的java_home保持一致,版本ha ...
- leetcode987
public class Solution { private Dictionary<int, List<KeyValuePair<int,int>>> dic = ...
- Office2019都有哪些强大功能
前阵子是微软一年一度的Ignite大会.而其中最引人注目.也是与我们一般人最息息相关的消息,当然是Office 2019的正式发布. 尽管Office 2019所更新的功能,对于Office 365的 ...
- FormData上传文件(不是所有的浏览器都支持)
<h1>Ajax上传文件</h1> <div> <input type="file" id="img"/> &l ...
- OC copy mutableCopy, 浅拷贝,深拷贝
copy与mutableCopy都是深拷贝,区别是mutableCopy拷贝出的对象是可变的. OC对象基本都是通过指针访问,所以一般情况下,通过对指针的赋值都是浅拷贝,即只是拷贝了一份对象的指针,对 ...
- css:调整placeholder样式
input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color: #C5CACF; } input:-moz ...