[英]React.memo prevent rendering redux nested data doesnt work
I am designing a messenger application on reactnative.我正在设计一个关于反应式的信使应用程序。
I have my redux store structured like this:我的 redux 商店的结构如下:
And this is my component which render:这是我渲染的组件:
When an event is added in store with my reducer, all of messages components are rendered each times even if React.memo equalTo return true.当使用我的 reducer 在 store 中添加一个事件时,即使 React.memo equalTo 返回 true,所有消息组件也会每次呈现。
Result:结果:
Expected result:预期结果:
Rendering only 1 time each MessageItem component (React.memo actually doesn't work, rendering even if propsEqualTo is true)每个 MessageItem 组件仅渲染 1 次(React.memo 实际上不起作用,即使 propsEqualTo 为 true 也会渲染)
Ok sorry for that, I just found the solution after 6h research and post here...好的,抱歉,我在 6 小时研究后才找到解决方案并在此处发布...
My React.memo component was rendering everytimes because I used a useSelector in it.我的 React.memo 组件每次都在渲染,因为我在其中使用了 useSelector。 I removed and now it's OK.
我删除了,现在可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.