expo / ex-navigation

Route-centric navigation for React Native
997 stars 201 forks source link

Updating a ListView inside a SlidingTabNavigation #397

Closed joeferraro closed 7 years ago

joeferraro commented 7 years ago

I'm finding that if I have a ListView inside a SlidingTabNavigation that I am unable to force the ListView to re-render when its dataSource is updated (when the ListView is not wrapped in SlidingTabNavigation it re-renders as expected). Is there something additional I need to do to force the SlidingTabNavigation to re-render its children?

satya164 commented 7 years ago

Move your ListView to separate component and do the updates inside the component.

joeferraro commented 7 years ago

@satya164 cheers. For anyone else who may encounter this issue: I had to move my ListView to a different component as @satya164 suggests, however, it's important to note I could not merely pass props from the component with SlidingTabNavigation down to the component with ListView. Rather, I had to connect the new component with redux in order for the ListView to re-render as expected.

JulianKingman commented 7 years ago

Oh man, this has been really hard to debug. Any idea why a component can't receive new props when it's inside SlidingTabNavigation?

satya164 commented 7 years ago

Navigation views are pure components for performance reasons. Since the props for sliding tab navigation doesn't change, it doesn't update.

JulianKingman commented 7 years ago

This seems related to this: https://github.com/exponent/ex-navigation/pull/361

It seems like react-navigation doesn't really handle this, either?