Skip to content

Instantly share code, notes, and snippets.

@franleplant
Last active January 3, 2017 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franleplant/bbd68356a4afda0245cc130a9e179517 to your computer and use it in GitHub Desktop.
Save franleplant/bbd68356a4afda0245cc130a9e179517 to your computer and use it in GitHub Desktop.
On React Native performance

On React Native performance

This is the post-mortem report about the performance problems found mostly in Android but also, in a lesser extend in iOS.

__DEV__ = false

This has a huge impact in the performance. By my measures, about 4x times faster. So be sure to that the app is in production mode before reporting any performance issues.

react-native-svg

SVGs are really slow compared to other components. They can take up to 90ms to render so be careful with them. One technique that helped us a lot is delaying the rendering of SVGs in Forms until the Router Transitions are done. We have a new reusable High Order Component to do that: providePartialRender.

The delay improves a lot the initial rendering performance and also improves a lot the Router Transition.

react-native-router-flux

Router transitions are very performance critical. In the experiments I've made, you should not do anything in JS until that transition is done. Try to reduce the amount of Scene Rendering to 1 until the transition is done. Also, any Redux state change might impact the transition performance.

The important part is that transitions are made in Javascript, so they are very performance intensive, so don't do anything else (much less rendering stuff) while that's happening.

rendering in router transitions = disaster

One particular case (Edit My Account) that threw the performance of the transition of the charts was the fact that we were doing some initial data fetching on componentDidMount, and that data fetching in turn changed the App State, and since on every App state change redux re-renders the component the result was that the Scene Component (Profile.tsx) was rendering a couple of times while the Router transition was being shown, and that impacted severely to the performance of the transition.

console.log

console.log has a very unexpected impact to performance, that's why we are disabling redux-logger on production builds. If you are experiencing performance problems (on transitions for example) be sure to check the console and see if we are logging a lot of stuff, which is bad!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment