I have worked on many React codebases during my career. But one of them stands out from the rest. It was truly horrible to work with.

Now I know from experience that most codebases seem horrible when you first take a look at them. Usually, this feeling subsides. But that did not happen here.

Hand-drawn meme showing the code review reactions to good code and bad code
The only valid measurement of code quality

From what I have heard and seen, it seems that the project was built by a developer who didn't have much experience with React or frontend development and they made a series of bad decisions. Eventually, the company found out about the true state of the codebase as it hogged all the resources and they brought me on board to try and mend it.

I think a lot can be learned from this codebase. So over the next few months, I will go over some of the horrible stuff I found on that codebase and how I tried to mitigate it. The solutions I came up with are probably not perfect but I think they were an improvement.

Since this is a real codebase, I can't disclose much information about it. But I can say that it is a Next.js web app with tens of thousands of users every month. Yes, Next.js is not the same as a React SPA but I think most of the issues I found are also relevant to React SPAs so I will call this series "Lessons from a bad React codebase".

You can sign up using your e-mail below to not miss any posts in this series!

Hand drawn sketch of the React logo standing in front of a blackboard holding a pointer
Prabashwara Seneviratne (bash)

Written by

Prabashwara Seneviratne (bash)

Lead frontend developer