How to make React Native mobile application faster?

前端 未结 5 643
盖世英雄少女心
盖世英雄少女心 2021-02-02 15:45

React Native mobile application is working very slow on every click. I am using react native v0.40.0 and following are the dependencies of my proje

5条回答
  •  执念已碎
    2021-02-02 16:08

    If mqt_js is the main cause of performance issue, that means in every click, the JS thread of your app has too many things to do at once. Communication between JS business logic and underlay native realm is done asynchronously, the more actions need to be finished in JS side when a button is pressed, the slower the app will be.

    Answer given by Pritish Vaidya already hits the nail on the head. I just want to include 1 more point about the usage of redux in your app. If your app's data flow is mainly done using redux then you can check for following things:

    • If there are too many redux actions happening on each clicking event, try to remove unnecessary ones or prioritise actions triggering important animations first, then triggering other actions once new RN components finished rendering. You can see which actions are bottomneck ones by redux-logger.

    • Break components listening to redux's store into smaller ones, with each listening to a different part of the store. So if redux's store is updated, only a small group of components should be rerendered instead of everything.

    • Use memoized selectors to deal with frequently updated data. reselect can help you in this case.

提交回复
热议问题