React & event-pooling & bug
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.
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的更多相关文章
- React event
React event 组件: React 自有方法 用户定义方法 一.虚拟事件对象 事件处理器将会传入 虚拟事件对象 的实例,一个对浏览器本地事件的跨浏览器封装.它有和浏览器本地事件相同的属性和方法 ...
- React & `event.persist()`
React & event.persist() event.persist() https://reactjs.org/docs/events.html#event-pooling Tabs ...
- React render twice bug
React render twice bug React bug constructor render twice bug update render twice bug StrictMode htt ...
- taro 小程序 & touch event 转换 bug
taro 小程序 & touch event 转换 bug before after 事件处理 https://nervjs.github.io/taro/docs/event.html#do ...
- React使用笔记(3)-React Event Listener
Date: 2015-11-28 12:18 Category: Web Tags: JavaScript Author: 刘理想 [toc] 1. 构造基本结构 首先,我们先创建一个按钮,一个输入框 ...
- React——event
1.绑定在React元素上的事件与绑定在DOM元素上的事件非常相似,但是也有一个不同的地方 React事件使用驼峰命名法命名 //在HTML中 <button onclick='handle() ...
- 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 ...
- react与jQuery对比,有空的时候再翻译一下
参考资料:http://reactfordesigners.com/labs/reactjs-introduction-for-people-who-know-just-enough-jquery-t ...
- 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, ...
- React 介绍
ttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind The sm ...
随机推荐
- python中的__all__
在定义一个模块的时候,在开头处加上 “ __all__ = ["xxx1", "xxx2"] ”(xxx可以是方法.类.变量等希望让外界访问的值),那么在外部通 ...
- golang区块链开发的视频教程推荐
目前网上关于golang区块链开发的资源很少,以太坊智能合约相关的课程倒是很多,可能是由于前者的难度比后者难度大,课程开发需要投入更多精力.搜了一圈之后没结果,我就直接去之前没覆盖的视频网站找资源,包 ...
- Go语言中的变量
1 概述 变量(Variable)是程序运行过程中,内容可以变化(修改)的量,变量的功能是存储用户的数据,是计算机语言中能储存计算结果或能表示值抽象概念.变量,是通过变量的标识符定位值的过程.变量的内 ...
- shell基础笔记
什么是shell脚本 我自己对shell脚本的理解就是一系列的shell命令加入逻辑关系,实现类似"批处理"的功能.而不是简单的命令的堆砌,那样的shell脚本bug重重. 脚本开 ...
- gp与 pg 查询进程
select now()-query_start as cost_time,* from pg_stat_activity where current_query not in ( '<IDLE ...
- struts2学习笔记四
一.contextMap中的数据操作 root根:List 元素1 元素2 元素3 元素4 元素5 contextMap:Map key value application Map key value ...
- Android Studio 引入 Git 并提交代码
File -> Settings -> Version Control -> Git -> Path to Git executable -> 选择本地 Git 可执行文 ...
- Luogu P1802 5倍经验日_KEY
题目传送门 ·背包 这可以说是一道背包的变形. 首先需要考虑到的是如何将ta转换为一个正常 的背包. 这些数据有一个让我们都十分不爽的地方就是有两个值. 所以我们就设置一个基准值,将失败的经验值当做基 ...
- 北京Uber优步司机奖励政策(12月31日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 天津市人民优步Uber司机奖励政策(9月14日~9月20日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...