React: Improve Performance With Memo()

React:  Improve Performance With Memo()

In this article, I provide some tips that can optimize or I can say improve the performance of your react app. Many times we got so many components on the same screen and eventually, that will take a lot of time to render.

In this article, I provide some tips that can optimize or I can say improve the performance of your react app. Many times we got so many components on the same screen and eventually, that will take a lot of time to render.

Mostly I use pagination or virtualization for most apps. Pagination provides a good user experience and that’s the most needed thing while developing an app, but what if you have a case where you need to render many components on the same screen plus not giving up on the UX and app’s performance. Check this preview of the app. It has an App component and a Square component.

// App.jsx
import React, { useState } from "react";

import Card from "./components/square/square";

const data = Array(30000)
  .fill()
  .map((val, index) => {
    return { id: index, key: `square-${index}` };
  });

const App = () => {
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>Count: {count}</p>
      {data.map(({ key }) => (
        <Card
          key={key}
          onClick={() => {
            setCount(val => val + 1);
          }}
        />
      ))}
    </div>
  );
};

export default App;
// Square.jsx
import React from "react";

import "./square.css";

const Square = ({ onClick }) => {
  return <div className="square" onClick={onClick} />;
};

export default Square;

programming reactjs coding javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Principles of Functional Programming in JavaScript That Will Make Your Coding Life Easier

Who else loves to write side-effects-free functions? I think we, as programmers, all do. Today, in this story, I will walk you through the basic principles of functional programming that will make your coding life easier.

ReactJS: The Javascript Developer’s Guide

This article will walk you through the concepts you would need to know to step into the world of widely used ReactJS.

4 Ways You Can Get Rid of Dirty Side Effects for Cleaner Code in JavaScript

4 Ways You Can Get Rid of Dirty Side Effects for Cleaner Code in JavaScript. Bugs are born in many ways. Creating side effects is one of them. Some people say side effects are evil, some say they’re not.

Who Else Wants to Write Clean JavaScript Code?

Who Else Wants to Write Clean JavaScript Code? 7 Tips to Make Your Coworkers Fall in Love With Your Code.

Code Formatting with Prettier in Visual Studio Code

Formatting code consistently is a pain, especially when working on a team. The beauty of modern-day web development is that the tooling has gotten so much better! In this article, we will look at setting up Prettier to automatically format your code in Visual Studio Code.