Sitemap
Mrinal Maheshwari

Mrinal Maheshwari

React Native dev & architect sharing dev insights, performance tips, regex magic, caching, animations, and offline-first mobile app strategies.

Member-only story

Optimizing Code in React Native

3 min readFeb 5, 2023

--

Press enter or click to view image in full size

Not a member? Read for FREE

React Native is a popular platform for building mobile applications for iOS and Android, but it’s important to ensure that your code is optimized for performance. Here are some tips to help you optimize your React Native code and make your app run smoothly.

Use Native Modules

Wherever possible, use native modules to perform complex operations like facial recognition, video or photo editing instead of JavaScript. Native modules are written in platform-specific languages like Java for Android and Objective-C (and Swift with help of bridging headers) for iOS and are faster than JavaScript code.

Reduce the number of Re-renders

Re-renders can slow down your app, so it’s important to minimize them. Use the shouldComponentUpdate lifecycle method and the React.memo or useMemo()higher-order component to prevent unnecessary re-renders. To know the code because of which application is re-rendering one can use library named why-did-you-render to get insights of code causing re-rendering issues.

The memo higher-order component is used to optimize the performance of a functional component by memoizing it. This means that the component will only re-render if its props have changed. In the example above, the…

--

--

Mrinal Maheshwari
Mrinal Maheshwari

Written by Mrinal Maheshwari

React Native dev & architect sharing dev insights, performance tips, regex magic, caching, animations, and offline-first mobile app strategies.