rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

Preferred way to load heavy screens

Open brentvatne opened this issue 6 years ago • 29 comments

Moved from https://github.com/react-navigation/react-navigation/issues/4578


This is a discussion issue. If you feel it does not go here, please just close it. For me this is the most important point of navigation: Navigate without lag.

I am using in this case react-native-calendars, in their example of course they use react-native-navigation. So I am trying it with react-navigation. This is an example of a "heavy" screen but I am sure there are many others.

This example is as it is (as I'd do it in just native Android):

im_off

This example uses InteractionManager.runAfterInteractions and shows a loading spinner first:

im_on

This next example uses requestAnimationFrame to change the state and make it visible:

raf

All examples are with JS minified in one of the highest end Android devices (Pixel 2).

The first example is definitely laggy (I guess in lower devices even more) and the second and third feel slow to me if you come from checking native apps with similar components like a calendar. I know the limitations so I am asking myself if I can do something better or we are in this point right now?

I know there is this post about State of React Native 2018 and things like new core and async rendering can probably help.

One of my thinkings is that even that React Native docs state:

The views in React Navigation use native components and the Animated library to deliver 60fps animations that are run on the native thread.

So even that you use useNativeDriver as much as possible, that does not really solve the problem. What are your thoughts on this? :)

Btw, I actually opened a similar discussion in https://github.com/wix/react-native-navigation/issues/3432 with the same example using their library (if you are interested).

brentvatne avatar Jun 26 '18 20:06 brentvatne