Lucifier129 / react-lite

An implementation of React v15.x that optimizes for small script size
MIT License
1.73k stars 98 forks source link

react-dom扩展出来unstable_batchedUpdates,react-lite能不能也开放这个api #87

Closed hufeng closed 7 years ago

hufeng commented 7 years ago

Hi @Lucifier129 聚大大,

在ReactDom中,对外暴露了unstable_batchedUpdates这个api, import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';

这个api对于解决react的一些级联渲染非常有用,比如redux的connect相互嵌套。 如:https://github.com/reactjs/redux/issues/125

Lucifier129 commented 7 years ago

好,我找时间研究一下,看看能不能提供~

hufeng commented 7 years ago

love @Lucifier129

这样就试着把我们移动端的项目切到react-lite, 非常期待!

主要我们写的iflux2 为了避免relax嵌套导致的级联渲染,也用了这个api。

hufeng commented 7 years ago

不清楚,是不是聚大大把这个暴露出来就可以了。 https://github.com/Lucifier129/react-lite/blob/master/src/ReactDOM.js#L77

Lucifier129 commented 7 years ago

我迁移了 ReactUpdates 的单元测试到 react-lite,看了一下具体行为,发现这一版的 react-lite 不能直接兼容这个 feature。

这个 feature 的影响范围很广,可以劫持 setState、receiveProps、forceUpdate 等各种更新途径,并且还可以无视 shouldComponentUpdate -> false 去更新组件,与特定内部 hook 实现方式有关,目前 react-lite 的实现方式没有预留这么强大的 hook。

等后面的版本支持这个特性时,我会在这里 @ 你;到时你再考虑哈~

Lucifier129 commented 7 years ago

暂时关掉,将来有变化时再重开