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计算框 ...
随机推荐
- HDFS在web端无法访问文件
解决办法1: [root@djt002 hadoop]# vi /etc/selinux/config 改为 SELINUX=disabled 解决办法2: 查看你的$HADOOP_HOME/etc/ ...
- Install Python on Mac (Anaconda)
Install Python on Mac (Anaconda) 标签(空格分隔): 运维 This blog is copy from the link: https://medium.com/@G ...
- C#面向对象基础2
一.属性 作用:保护字段,对字段的赋值取值进行限定 意思是在初始化对象的时候防止出现不是事实的违规操作 如将性别赋值为‘中’ 本质:两个方法 get方法和set方法. p ...
- 《算法》第四章部分程序 part 6
▶ 书中第四章部分程序,加上自己补充的代码,图的环相关 ● 无向图中寻找环 package package01; import edu.princeton.cs.algs4.In; import ed ...
- Tomcat 之session 持久化1
Tomcat 之session 持久化原理 几个概念: Manager 接口,其实就是指的是对 其Sesison 的管理, 其默认实现是StandardManager (内部没有任何Store对象实 ...
- Centos7 用户登录失败N次后锁定用户禁止登陆
参考网站:https://blog.csdn.net/qq_33285112/article/details/78813369 未试 思路是查找/var/log/secure中验证失败且出现的次数较 ...
- Ubuntu系统tensorflow安装问题及解决
su root ps:如果你没有改过root密码,sudo passwd 然后输入你的账户密码,然后设置你的root密码 在root权限下执行pip install --upgrade pip 更 ...
- python大法好——字典、集合
字典 前面我们说过列表,它适合于将值组织到一个结构中并且通过编号对其进行引用.字典则是通过名字来引用值的数据结构,并且把这种数据结构称为映射,字典中的值没有特殊的顺序,都存储在一个特定的键(key)下 ...
- PHP 文件操作类(转载)
<?php class File { /** * 创建多级目录 * @param string $dir * @param int $mode * @return boolean */ publ ...
- Set和Map数据
es6新的数据结构 1.Set:构造函数 const s = new Set ([1,2,3]); console.log(s)//Set(3){1,2,3};[...s];//[1,2,3]cons ...