Member-only story

6 Regrets I Have As a React Developer

Mohammad Faisal
Better Programming
Published in
4 min readFeb 1, 2021
A young man with his head in his hands
Photo by Francisco Gonzalez on Unsplash

React is a great tool to learn. It allows us to do things in our own way. It's both powerful and limiting at the same time.

For new developers, there’s no clear guideline on which tool is best for which use case, and as a result there are multiple solutions to every problem. And sure enough, I also fell into this mistake and was late to adopt some best practices.

Today I am sharing the top 6 things that I should have started doing earlier in my React development journey.

1. Testing

For a long time testing was my weakness. I didn’t write tests for my components and, as expected, often I had to debug typos.

But as daunting as it may look, testing in React is really easy (For most use-cases).

Adding a very basic test that takes two minutes to write can save hours in the long run. Here’s a test that checks if the Title component will render correctly:

it('checks if the title component is in the document', () => {
expect(screen.getByText('Title')).toBeInTheDocument()
})

If you are using create-react-app you already have the testing setup in place. Just start writing tests as much (and as early) as possible.

2. Using the Correct Folder Structure

I think as a beginner in React my biggest mistake was not using the correct folder structure. Essentially what I did was group files according to their type:

|-store  |--actions
|---UserAction.js
|---ProductAction.js
|---OrderAction.js
|--reducers
|---UserReducer.js
|---ProductReducer.js
|---OrderReducer.js

But as the project grew bigger it was getting tougher to find any file.

So finally I started to organize my files by feature. That means all the similar files are now put in the same folder:

|-store  |--user
|---UserAction.js
|---UserReducer.js
|--product
|---ProductAction.js
|---ProductReducer.js

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (13)

Write a response