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 ...
随机推荐
- poj2676 (dfs+回溯)
Sudoku Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 24108 Accepted: 11259 Specia ...
- 成都优步uber司机第一组与第二组的区别
成都优步uber司机被分成了两组,两组的奖励方式不相同,下面我们先来看看官方给出的奖励方式: 滴滴快车单单2.5倍,注册地址:http://www.udache.com/如何注册Uber司机(全国版最 ...
- 成都Uber优步司机奖励政策(1月29日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- LeetCode:34. Search for a Range(Medium)
1. 原题链接 https://leetcode.com/problems/search-for-a-range/description/ 2. 题目要求 给定一个按升序排列的整型数组nums[ ]和 ...
- VINS(二)Feature Detection and Tracking
系统入口是feature_tracker_node.cpp文件中的main函数 1. 首先创建feature_tracker节点,从配置文件中读取信息(parameters.cpp),包括: ROS中 ...
- 使用duplicateweedout
mysql> explain extended select * from cities where id in (select phonecode from countries group b ...
- mysql源码
从代码的角度来说,没有丝毫设计感,尤其是优化器部分.不过那些是常年累积的原因,一些新加较独立的部分,设计的就很舒服,真正的面向对象做法.
- Visual Studio 2015 Test Explorer does not show anything
Problem After install Visual Studio 2015 community and NUnit Test Adapter, I cannot find test cases ...
- RabbitMQ基础教程之使用进阶篇
RabbitMQ基础教程之使用进阶篇 相关博文,推荐查看: RabbitMq基础教程之安装与测试 RabbitMq基础教程之基本概念 RabbitMQ基础教程之基本使用篇 I. 背景 前一篇基本使用篇 ...
- Jmeter 接口自动化执行报错 无法找到类或者类的方法
写好的自动化测试脚本在PC以及mac book 都执行正确,但是放到linux集成环境时就一直报错,报错类似如下 [jmeter] // Debug: eval: nameSpace = NameSp ...