There are such a lot of methods to do that however listed below are few most most popular methods:-
- Use of shouldComponentUpdate methodology of react-native lifecycle
- Use Pure Elements of React
- Use Memo from Hooks API
- Construct the module with native at any time when it’s potential
- Take away the console logs earlier than constructing the applying
- Scale back Utility dimension
Use of shouldComponentUpdate
Utilizing shouldComponentUpdate methodology, we are able to scale back pointless re-rendering of elements.
shouldComponentUpdate returns the boolean worth and based on that elements will rerender. For instance, if it returns true then it would rerender and if it returns false then it won’t rerender part.
So, on state replace or on new props to the part this methodology can be known as with two arguments known as nextState and nextProps. So, you’ll be able to examine the brand new props and state with the earlier ones. And based on what you are promoting logic necessities, you need to use the boolean to render the part once more.
Use Pure Elements of React
The pure part of React helps to render solely the precise props which have been modified or the state has up to date.
For instance, if we’re utilizing a flatlist which is rendering 1000 rows. Now, on each rerender that 1000 information can be rendered once more.
Utilizing flatlist within the pure part we are able to make sure that solely the change on required props, elements will re-render once more.
Use Memo from Hooks API
React Hooks present the lifecycle of elements to capabilities.
Memo from react helps to do a shallow comparability on upcoming modifications. So, it permits re-rendering capabilities provided that the props get modified.
Construct the module with the native driver at any time when it’s potential
Right here, We aren’t speaking about not utilizing React Native. Generally, it occurs that we’ve to make use of some options which will be carried out by the native extra effectively. At the moment, we’ve to construct that module in native one and may use the function from the React Native by making a bridge.Advantages in Costing To Hiring Offshore React Native BuildersIonic Vs React Native – Which One To Decide For Your Undertaking?
Take away the console logs earlier than constructing the applying
It has been recognized that the console logs are taking some period of time for logging functions. So, it’s good to make use of on the time of improvement however within the manufacturing construct, it ought to be eliminated which can assist to enhance the efficiency of the app which you’ll notice whereas utilizing it.
Scale back Utility dimension
In React Native, you utilize exterior libraries and elements kind libraries so it impacts software dimension.
To cut back the scale, you must optimize the assets, use ProGaurd, create totally different app sizes for various machine architectures, and ensure to compress the graphics components, i.e. photos.