Showing posts with label react native apps. Show all posts
Showing posts with label react native apps. Show all posts

Friday, October 29, 2021

How To Optimize Performance Of React App?



Since the inception of React, it has transformed a way to build web applications. By using virtual DOM, React can make UI updates more efficiently. Mostly this makes web apps more irritable. Developers complain that medium sized react web apps perform so poorly and slowly. So here we came with some tips to optimize performance of react apps. Let’s have a look at those tips.

Also know the best react component libraries at- 10 Best React component libraries you should know in 2020

Tips To Optimize Performance Of React Apps-

React logo

1. Multiple Chunk Files-

Your app starts with a few components. You start adding new dependencies and features and before you know it, you end up with a big production file. Consider having separate two files by separating your vendor or third-party library code from app code by leveraging CommonChunkPlugin for webpack. You’ll end up with vendor.bundle.js and app.bundle.js. By dividing your files, browser caches less frequently and parallel downloads resources to minimize the load time wait. If you’re using latest version of webpack, consider SplitChunksPlugin.

2. Using Production Mode Flag In Webpack-

If you have used webpack 4 as a module bundler for your app, set the mode option to production. Basically it tells webpack to use the built-in optimization:

   module.exports = {
      mode: 'production'
    };

Alternatively, you can pass it as a CLI argument:

webpack –mode=production

This will limit optimizations, like minification or removing development-only code to libraries. It won’t expose source code, file paths and so on.

3. Function/Stateless Components and React.PureComponent-

In react development, function components and PureComponent provides two different ways of optimizing react apps at component level. Function components prevent constructing instances of class while minimizing the overall bundle size as it minifies better than classes. Conversely, so as to optimize UI updates, you can convert function components to PureComponent class. If component doesn’t use state and other life cycle methods, the initial render time is somehow more complex when compared to function components with faster updates. 

When to use React.PureComponent?

React.PureComponent does a shallow comparison on state change. Meaning that it compares values when looking at primitive data types and compares references for objects. Because of this, you must ensure two criterias fulfil when using React.PureComponent:

  • Props/State should not have multi-level nested object. 

Tip- All child component of React.PureComponent should be a Pure or functional component.

  • Component State/Props is an immutable object;

4. Use React.Fragments to Avoid Additional HTML Element Wrappers-

React.fragments allows you to group a list of children without adding an extra node.

class Comments extends React.PureComponent{
    render() {
        return (
            <React.Fragment>
                <h1>Comment Title</h1>
                <p>comments</p>
                <p>comment time</p>
            </React.Fragment>
        );
    } 
}

There is alternate and more concise syntax using React.fragments:

class Comments extends React.PureComponent{
    render() {
        return (
            <>
                <h1>Comment Title</h1>
                <p>comments</p>
                <p>comment time</p>
            </>
        );
    } 
}

5. Using Immutable Data Structures-

Thursday, September 30, 2021

How To Optimize React Native App Performance In 2021?

 

How To Optimize React Native App Performance In 2021?

How To Optimize React Native App Performance In 2021

Any app or product must have good performance to stand out in market competition. When you work with React native, you may face problems with the performance of your app. So you need to pay attention to performance improvements and best practices for react native app during its development, fix some issues and deliver a great experience to end users. Hence here we’ll discuss some of the tips and best practices to optimize react native app performance. But if you are confused to choose react native for mobile app development, have a look at- Why Use React Native For Mobile App Development?

Tips To Optimize React Native App Performance-

1. Resize And Scale Images-

Optimizing images is important to improve react native app’s performance if the app is built to show a large amount of graphical content or images.  If images are not properly optimized in terms of resolution and size, rendering of multiple images need high memory usage on the device. It may cause app crash because of memory overload. Here are some of the improvements to optimize images in react native app- 

  • Use of smaller resolution images
  • Use PNG format rather than JPG format
  • Using WEBP format for images – it reduces the binary size of image on iOS and android

2. Do Cache All Images Locally-

Catching is a way solve image problems that optimizes overall performance of react native app. But while caching images at the time of loading in your app, you have to save images locally. By caching images locally in the subsequent requests, you won’t just improve the app’s performance but also save a time of loading images. Now, it is time to recall the debate on cross-platform vs native app development for android and ios as here caching with the image component is for ios only not for android.

Let’s see a way to do local image caching:

<Image
  source={{
    uri: ‘https://unsplash.it/200/200?image=8’
    cache: ‘only-if-cached’
  }}
  style={{ … }}
/>

Though react native is particular about image components, it lacks some important solutions to reduce the impact of following issues- 

  • Reduced image loading speed
  • Attaching multiple images on single screen
  • Low app performance
  • Poor cache performance
  • Image flickering and cache misses

You should consider quick loading image format with react native libraries with great cross platform app development frameworks.

Know more at- https://solaceinfotech.com/blog/how-to-optimize-react-native-app-performance-in-2021/



Tuesday, March 17, 2020

Most common mistakes to avoid when creating a react native app


Applications have taken over our lives. According to Statista, more than 204 billion applications have been downloaded in 2019. It means the application industry is thriving, and many states that it will keep growing later on also!
As an ever increasing number of individuals use smartphones and thus applications, the industry has become a quiet advantageous opportunity for new entrepreneurs. Many wish to become wildly successful in the sector by developing the best application out of the lot.
But, application development is easier said than done!
The primary choice you should make as a developer is which programming tool to use to create a smooth and glitch free application. One alternative you should think about is to use React Native.

Why React Native?

React Native is a mobile application development framework that is developed by Facebook. It is an open-source platform that was launched in 2015.
Compared with all different cross-platform application development frameworks, React Native has proven to be the most preferred by many developers. This is because it allows developers to create an excellent quality application for the iOS and Android simultaneously!
Here are some basic advantages related with React Native:
  • It uses JavaScript which almost every developer knows inside and out
  • The React Native Framework has a very straightforward installation process
  • The live reload feature of the platform allows for a rapid application development
  • It is a cross-platform, in this way allowing developers to create solutions that can be adapted to Android, iOS, VR devices, smart TVs, and so on.

Mistakes to Avoid When Developing React Native App-

Here are the most well-known mistakes that an application developer can make when developing an application using React Native.

1. Wrong estimation- 

Layout for iOS and Android version – there will be various reusable components, however there could also be various layouts. Actually, the insignificant structure of an application page can be totally different on iOS and Android.
Forms – you should estimate the validation layout too. At the point when you create an application in React Native, you should write more codes compared to when you create a Hybrid application on suppose Cordova.
If creating Web application – You should check all the various endpoints which are offered by the backend. Also, because you should deal with the logic in the application, it should all be coded accurately. You should understand the database structure, how the entities are connected, and so on.

2. Wrong redux store planning-

Saturday, February 29, 2020

Amazing steps to optimize the performance of React Native Applications

React Native is developed by Facebook. And it has surely become one of the most favored JavaScript library code frameworks for developing cross-platform applications. In spite of the fact that the initial launch was in 2013 on GitHub however it has made more buzz in comparison with Xamarin and Ionic.
The one perspective that truly goes into the favor of the React Native is that it allows the developers to build mobile and web applications at a much faster pace. Additionally, you can build both the Android and iOS applications by sharing and reusing the codes easily.
Another benefit that React Native offers is that there isn’t much difference between completed applications developed using Objective-C or Java and React Native. React Native also has support from a network of great experienced engineers. It also has some drawbacks. Here you won’t find custom modules. You have to create your own module. Hence, here we will discuss ways to improve the performance of your React Native applications. Before we can reveal how to fix the performance issues related to React Native, you have to understand that the performance of this JavaScript library relies upon the architecture to much extent.
The increase in the number of navigation controls, the animation and tabs slows the speed of the UI in the application. During the upgrading of the application, the version tends to get changed and it can also turn into a key bottleneck in the application’s performance.
The React Native basically communicates with native thread with the help of a bridge. The architecture of the React Native can be categorized into two categories- the React Native developed on Java, Swift or Objective-C and the native created on JavaScript. Hence, we can focus on these important parameters to improve the performance.

Steps to optimize the performance of React Native Applications-

1. Reducing the Size of the Application-

The JavaScript framework applications rely generally upon the native components and third-party libraries. The more use of the components enhance the size of the application.
  • Hence, if you need to reduce the size of the application, you need to use ProGuard and also develop applications of variation sizes for a variety of device architecture.
  • Focus on the graphic elements and images
  • You can also find a way to reduce the size, for example, shifting the components from native to react native, reduce the size of the bridge that JavaScript uses to interact with native.
  • You can go through the open-source libraries to check its stability before using it.
  • Try not to use the main thread to pass the components depending on heavy message queues.


Read more at-