简体   繁体   中英

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:

店铺结构

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.

减速器

Result:

结果

Expected result:

Rendering only 1 time each MessageItem component (React.memo actually doesn't work, rendering even if propsEqualTo is true)

Ok sorry for that, I just found the solution after 6h research and post here...

My React.memo component was rendering everytimes because I used a useSelector in it. I removed and now it's OK.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM