react-native-paper-tabs icon indicating copy to clipboard operation
react-native-paper-tabs copied to clipboard

Initial load of tab screens rendered twice

Open goufang opened this issue 4 years ago • 5 comments

Is there a way to prevent all screens from re-rendering on initial load?

Thanks

goufang avatar May 16 '21 22:05 goufang

Wrap the subscreen in a React.memo should fix it there. Does this happen on the web version or ios/android?

RichardLindhout avatar May 17 '21 18:05 RichardLindhout

they are already wrapper with React.memo however still no luck. Also, each swipe action all of the TabScreens are loaded as well. I am using React Native IOS simulator

goufang avatar May 19 '21 03:05 goufang

Where do you put the React.memo? do you use the use the useTabIndex()?

RichardLindhout avatar May 19 '21 19:05 RichardLindhout

You need to

  <TabScreen label="Flights" icon="airplane">
          <Flights />
        </TabScreen>

Flights.tsx/js

function Flights(){
     console.log('re render flights')
     return View style={{ backgroundColor: 'black', flex:1 }} />
}
export default React.memo(Flights)

RichardLindhout avatar May 19 '21 19:05 RichardLindhout

Hi, thanks for this library, I have the same problem, I already apply React.Memo, also all the TabScreens are rendered at the beginning

(I'm using Expo, the project is in production, iOS and Android)

CristianFigueredo avatar Jan 08 '22 18:01 CristianFigueredo

Please provide a simple snack

RichardLindhout avatar Nov 23 '23 19:11 RichardLindhout