5 Essential React Practices I Learned on the Job

Cover image for 5 Essential React Practices I Learned on the Job

5 Essential React Practices I Learned on the Job

#react#javascript#webdev#bestpractices
Suraj Vishwakarma

Suraj Vishwakarma

Updated on 07 Aug, 2025


TL;DR

When I started my job at my organization, I thought I knew quite well, but there are some practices that I only knew but didn’t implement. It was not that complex with my project, as it was not complex enough. As the application grows, adhering to best practices becomes crucial to maintain a clean, scalable, and performing code.

Today, I am going to list down some of the React Essential Practices that I learned at my job. So, let’s get started.

Maintaining a Scalable Code Structure

Maintaining a Scalable Code Structure

A well-organized project structure is necessary to maintain a complex application that is going to grow bigger every day. In my organization, we divide Features into a separate folder with all the components that are specific to that feature in that folder only. This is a feature-based or module-based structure. Only components used throughout the entire application are created separately in the root folder.

React structure is sorted with starting with imports and ending with return, but what’s between them defines the code structure. Before starting the job, I didn’t have a proper code structure. In my organization, they use this code structure in order.

  1. Imports: All the necessary modules should be imported at the top. If it gets bigger, then divide with a line break to differentiate between UI components import and other.
  2. Constants: After import, rather than defining a React function, we define any constants such as dropdown options, initial value, etc.
  3. React Function: Now we define our React functions here.
  4. Variable Definition: Defining variables with the useState hook.
  5. Function: After the variable definition, we start by defining any functions that are required, such as JS functions, API call functions, etc.
  6. useEffect Calls: This was always after the function to make sure the useEffect can be called. I made a mistake by defining a function, then useEffect, then a function, and then useEffect.
  7. Return: Now return your React function.

Recommended Tools:

Restrict Unnecessary API Calls

Restrict Unnecessary API Calls

With a smaller application, you are going to make very few API calls, max 2 per file. But with a complex application, you might need to trigger the API fetch with new query params. One such situation, where we have a table to display information, and now we are working on the to add Filters. There were quite a lot of Filters, like almost 10 filters with different scenarios. So we made mistakes like calling unnecessary API calls due to some other scenario with is not required or making twice the initial call because in useEffect from the previous code was changing.

So, what I learn like making the Application make only necessary calls. This can be done using a few useEffect so that you don’t need to maintain a lot of useEffect that can make an API call as a side effect of that. By restricting calls, you will reduce the server load, lower data transfer costs, and have a much smoother application.

Recommended Tools:

Use State Management over Prop Drilling

Prop Drilling

Prop drilling is the process of passing state through multiple layers of nested components, even if the intermediate layer is not required. I did for a feature and was corrected by colleagues regarding that, using a Management state rather than props drilling. It can be helpful in case of when passing a state through React navigation.

Using a statement management solution makes the components simpler, simplifies state logic, and makes the application's data flow predictable and easier to debug.

Recommended Tools:

Pagination for Web, Infinite Scroll for Mobile

Pagination

This is not a code practice but a product design choice to make the application more responsive and useful. This can be helpful when there is large data that you might need to display. At my organization, we use React for web and mobile. For mobile, it is embedded in a mobile application. Here is the choice with an explanation.

Recommended Tools:

Do a Unit Test Before Handing Off to QA

Unit Testing

Note: The Above image is from headspin.

It is not just React, but whenever you write a piece of code, testing has to be done. Even if there is a QA team, you first need to test the feature by yourself to make sure you give a more stable product to QA for testing. Initially, when I started, I used to just design and then integrate the application, and move the feature to QA, which resulted in quite a lot of bugs. So my colleagues advised me to do proper unit testing at my end before handing it to the QA team.

Doing unit testing will definitely increase the development time, but will make the feature go live sooner, and you will be dealing with fewer bugs in the future.

Recommended Tools:

Connect with Me🚀

Let's connect and stay informed on all things tech, innovation, and beyond!

Also, I am open to writing freelance articles if you are interested; then contact me via email or social media.

Conclusion

Mastering these practices for code structure, state management, data fetching, and testing is the key to engineering professional React applications. This foundation allows you to build products that are not only scalable and performant but also a pleasure for your team to maintain.

I hope you like the article. Thanks for reading the article.


Build by Suraj Vishwakarma.