React & event-pooling & bug

event-pooling

https://reactjs.org/docs/events.html#event-pooling

https://reactjs.org/docs/events.html#mouse-events

https://reactjs.org/docs/events.html#form-events

old


// old result = (
<Input
// unique key
key={type}
value={Filter_Value}
onChange={that.onFilterValueChange}
// onChange={(e) => that.onFilterValueChange}
placeholder={placeholder}
/>
);

new

// new
result = (
<Input
// unique key
key={type}
value={Filter_Value}
onChange={(e) => that.onFilterValueChange(e)}
// onChange={(e) => that.onFilterValueChange}
placeholder={placeholder}
/>
);

bug

react & Warning: This synthetic event is reused for performance reasons.

https://stackoverflow.com/questions/49500255/warning-this-synthetic-event-is-reused-for-performance-reasons-happening-with

binding bug & event Bubble ???

// 1. change below
onChange={this.handleCheckbox}
// to
onChange={() => this.handleCheckbox} // 2. If that won't work, in 'handleCheckbox' add this line
handleCheckbox = (event) => {
event.persist();
this.setState({
isChecked: !this.state.isChecked
});
};

I think the is that when using an array.map() function will create many same items if the item without a unique key, React couldn't tell which one child triggered the event, so it may be coursed a crash. Therefore, using ES6 arrow function will auto bind this to the unique one item.

我认为, 当使用 "array. map ()" 函数将创建许多相同的项目, 如果没有唯一的键的项目, 反应无法判断哪个孩子触发了事件, 所以它可能会导致崩溃。 因此, 使用 es6 箭头函数将自动绑定 "此" 到唯一的一个项目。

solutions

https://www.duncanleung.com/blog/2017-08-14-fixing-react-warnings-synthetic-events-in-setstate/

https://stackoverflow.com/questions/42089795/reactjs-cant-set-state-from-an-event-with-event-persist

React & event-pooling & bug的更多相关文章

  1. React event

    React event 组件: React 自有方法 用户定义方法 一.虚拟事件对象 事件处理器将会传入 虚拟事件对象 的实例,一个对浏览器本地事件的跨浏览器封装.它有和浏览器本地事件相同的属性和方法 ...

  2. React & `event.persist()`

    React & event.persist() event.persist() https://reactjs.org/docs/events.html#event-pooling Tabs ...

  3. React render twice bug

    React render twice bug React bug constructor render twice bug update render twice bug StrictMode htt ...

  4. taro 小程序 & touch event 转换 bug

    taro 小程序 & touch event 转换 bug before after 事件处理 https://nervjs.github.io/taro/docs/event.html#do ...

  5. React使用笔记(3)-React Event Listener

    Date: 2015-11-28 12:18 Category: Web Tags: JavaScript Author: 刘理想 [toc] 1. 构造基本结构 首先,我们先创建一个按钮,一个输入框 ...

  6. React——event

    1.绑定在React元素上的事件与绑定在DOM元素上的事件非常相似,但是也有一个不同的地方 React事件使用驼峰命名法命名 //在HTML中 <button onclick='handle() ...

  7. React 17 All In One

    React 17 All In One v17.0.1 https://reactjs.org/blog/2020/10/20/react-v17.html https://reactjs.org/b ...

  8. react与jQuery对比,有空的时候再翻译一下

    参考资料:http://reactfordesigners.com/labs/reactjs-introduction-for-people-who-know-just-enough-jquery-t ...

  9. ANGULAR 2 FOR REACT DEVELOPERS

    Now that Angular 2 is in beta, the time has come for us to drop everything and learn something new, ...

  10. React 介绍

    ttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind The sm ...

随机推荐

  1. I2C软件模拟协议与电容触摸控制

    I2C 与 Touch slide 最近做了一个与触摸滑条相关的测试,利用I2C通讯协议来配置触摸控制芯片的相关寄存器,读取触摸读数,并通过STM Studio动态显示触摸读数的变化过程.这个测试相对 ...

  2. TCP/IP协议族、版本以及编址机制

    TCP/IP协议族简称TCP/IP.这么命名是因为该协议家族中的两个核心协议:TCP(传输控制协议)和IP(网际协议),为该家族中最早通过的标准.TCP/IP提供点对点的链接机制,将数据应该如何封装, ...

  3. Shr-前端汇总

    F7控件监听 f7控件的监听是指,在点击F7控件时,对控件内的内容进行选中后出发该事件监听:通过参数value可以获取当前F7控件的一些值信息. //人力编制方案监听 回写计划期间 及分录数据 ini ...

  4. Python:pickle模块学习

    1. pickle模块的作用 将字典.列表.字符串等对象进行持久化,存储到磁盘上,方便以后使用 2. pickle对象串行化 pickle模块将任意一个python对象转换成一系统字节的这个操作过程叫 ...

  5. Error starting mongod. /var/run/mongodb/mongod.pid exists.启动mongodb报错

    linux上安装mongodb,启动时报上面的错,解决如下: 解决方法: 1.删除mongod.pid文件 rm -rf /var/run/mongodb/mongod.pid 2.修改/tmp/mo ...

  6. Spring Boot中使用缓存

    Spring Boot中使用缓存 随着时间的积累,应用的使用用户不断增加,数据规模也越来越大,往往数据库查询操作会成为影响用户使用体验的瓶颈,此时使用缓存往往是解决这一问题非常好的手段之一. 原始的使 ...

  7. WeTest功能优化第1期:截图960px,云真机映射功能了解

    第1期功能优化目录 [全线产品测试截图优化]安卓机型测试截图分辨率上升至960px [云真机新增Android 9]最新安卓系统,等你pick [云真机新增键盘映射功能]电脑键盘码字,云真机同步显示  ...

  8. cf#516C. Oh Those Palindromes(最多回文子串的字符串排列方式,字典序)

    http://codeforces.com/contest/1064/problem/C 题意:给出一个字符串,要求重新排列这个字符串,是他的回文子串数量最多并输出这个字符串. 题解:字典序排列的字符 ...

  9. Unity编辑器 - 使用GL绘制控件

    Unity编辑器 - 使用GL绘制控件 控件较为复杂时,可能造成界面卡顿,在EditorGUI中也可以灵活使用GL绘制来提升性能. 以绘制线段为例: using UnityEngine; using ...

  10. python爬虫基础之一(爬淘宝)

    没想到python如此强大, 今天看一会视频学会了一段python爬虫 这就是我今天学到的内容爬去淘宝网关于书包的一些信息,包括价格, #coding=utf-8 import requests#导入 ...