CJY0208 / react-activation

Hack <KeepAlive /> for React
https://www.npmjs.com/package/react-activation
MIT License
1.78k stars 140 forks source link

触发了useLayoutEect和comDidMount 导致问题 #320

Closed lsy934127847 closed 1 month ago

lsy934127847 commented 1 month ago

在使用antd 时, 缓存激活时触发了 componentDidMount 钩子,导致数据被重置了。 image

问题: react-activation 为何会触发 useLayoutEffect 和 componentDidMount

CJY0208 commented 1 month ago

related: https://github.com/CJY0208/react-activation/issues/225#issuecomment-1311136388

lsy934127847 commented 1 month ago

在react18中, 我点的特别快,不会触发useLayoutEffect 点的慢一点就触发了, 这是什么原因? 20240717160520 这样导致antd 的 initvalue 不能使用, 会触发

CJY0208 commented 1 month ago

因为keep alive的freeze行为会有一定延迟 ,具体解决方案看我关联的链接

---原始邮件--- 发件人: @.> 发送时间: 2024年7月17日(周三) 下午4:07 收件人: @.>; 抄送: @.>;"State @.>; 主题: Re: [CJY0208/react-activation] 触发了useLayoutEect和comDidMount 导致问题 (Issue #320)

在react18中, 我点的特别快,不会触发useLayoutEffect 点的慢一点就触发了, 这是什么原因? 20240717160520.gif (view on web) 这样导致antd 的 initvalue 不能使用, 会触发

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

lsy934127847 commented 1 month ago

主要是为何会触发 useLayoutEffect 和 componentDidMount 不会触发 useEffect? 有一个很好的解释吗

CJY0208 commented 1 month ago

related: https://github.com/CJY0208/react-activation/issues/225#issuecomment-1311136388 image

lsy934127847 commented 1 month ago

如果 用了 这个 autoFreeze={false} 性能影响大吗?在react18中加了这个可以解决触发layouteffect的问题, react16.14还有点问题

lsy934127847 commented 1 month ago

那个initvalue 不要写在form.item 上 写着外层的form上, 因为外层的initvalue 不是走的生命周期 image