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 toonClickthis 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的更多相关文章

  1. java event

    What is an Event? Change in the state of an object is known as event i.e. event describes the change ...

  2. c# 关键字delegate、event(委托与事件)[MSDN原文摘录][1]

    A delegate is a type that safely encapsulates a method, similar to a function pointer in C and C++. ...

  3. Adobe Scout 使用参考说明

    Adobe Scout 用于优化 Flash 内容,是一款极为强大的工具,因为它能让您看到 Flash Player 幕后正在发生的事情.但是若明白 Flash Player 为什么做这些事情,您看到 ...

  4. YARN集群维护部分问题汇总

    云梯开发人员在云梯Yarn集群的搭建和维护过程中做了许多工作,本文选择这期间部分较为典型的问题,通过对这些问题的分析和解决方案,为大家分享分布式系统问题调查的经验. 调查的问题 1. 2013年初引入 ...

  5. Windows api 函数全部列表 (未完成)

    网上找了很久,发现没有完整版的,msdn上面有,但是不方便查阅,所以想自己整理一下:由于工程量过于庞大,希望大家共同完成.MSDN:http://msdn.microsoft.com/en-us/li ...

  6. jquery autocomplete ajax获取动态数据,兼容各浏览器,支持中文

    jquery.autocomplete.js经过改动,支持各种浏览器.支持中文输入! 1.效果图例如以下 2.HTML和ajax代码 <!DOCTYPE html> <html xm ...

  7. FusionCharts for Flex的属性和事件

    FusionCharts for Flex的属性和事件 1.Properties(属性) (1)FCChartType (2)FCDataURL (3)FCDataXML (4)FCDebugMode ...

  8. ABP EventBus(事件总线)

    事件总线就是订阅/发布模式的一种实现    事件总线就是为了降低耦合 1.比如在winform中  到处都是事件 触发事件的对象  sender 事件的数据    e 事件的处理逻辑  方法体 通过E ...

  9. Hadoop YARN架构设计要点

    YARN是开源项目Hadoop的一个资源管理系统,最初设计是为了解决Hadoop中MapReduce计算框架中的资源管理问题,但是现在它已经是一个更加通用的资源管理系统,可以把MapReduce计算框 ...

随机推荐

  1. 阅读别人的程序(Java篇)

    1.递归求数组最大值 2.转账(事务) 1.递归应用 public class DiGuiDemo3 { public static void main(String[] args) { int[] ...

  2. SQLServer树查询

    感觉这个CTE递归查询蛮好用的,先举个例子: use City; go create table Tree ( ID int identity(1,1) primary key not null, N ...

  3. EXCEL workbook.saveas 函数详解

    本问所有资料来自于 Excel2003 VBA帮助文件,张荣整理,适用于DELPHI,VB的高级语言操作Excel用 ExcelApplication.WorkBook.SaveAs(filename ...

  4. ubuntu上virtualbox无法找到usb设备【解决】

    How to set up USB for Virtualbox? USB in different versions of Virtual Box For use of USB in Virtual ...

  5. linux配置防火墙,开启端口

    Centos7,配置防火墙,开启端口 1.查看已开放的端口(默认不开放任何端口) firewall-cmd --list-ports 2.开启80端口 firewall-cmd --zone=publ ...

  6. Yii框架中使用SRBAC作为权限管理模块时遇到的问题

    Yii框架中使用SRBAC作为权限管理模块时遇到的问题   看到Yii中提供RBAC的插件,SRBAC,就想用用. 结果按照手册上的安装办法,整来整去,安装完了,可就是进不了权限管理界面. 最后想到, ...

  7. .Net MVC 身份验证

    .Net身份验证主要是分为三种 Windows | Forms | Passport ,其中Froms在项目中用的最多. Windows 身份验证 Forms 验证 Passport 验证 1.Win ...

  8. python大法好——编码.文件

    1.编码 python3 中使用utf-8作为默认编码. UTF-8对Unicode进行转化,为解决存储和网络传输问题. UTF是为Unicode编码设计的一种在存储和传输节省空间的编码方案. Uni ...

  9. Swoole 异步mysql使用

    <?php class mysql { private $param; public $db; public function __construct() { $this->db = ne ...

  10. WPF中TextBox文件拖放问题

    在WPF中,当我们尝试向TextBox中拖放文件,从而获取其路径时,往往无法成功(拖放文字可以成功).造成这种原因关键是WPF的TextBox对拖放事件处理机制的不同,具体可参考这篇文章Textbox ...