Better Programming

Advice for programmers.

Follow publication

The 7 Traits of a Rock Star React Developer

Habits that make the difference

Mohammad Faisal
Better Programming
Published in
4 min readMar 3, 2021
A man sits at a laptop coding.
Photo by Danial Igdery on Unsplash

Getting the job done is the most important thing in software development. But how do you separate yourself from others? Well, from my experience, I can say the difference is in the approach.

Over the years, I’ve worked with several React developers. Here are some things that separate a great developer from an average one.

1. They Don’t Use Index as the Key

When we render a list, we usually get a warning saying we need to provide a key for each list item. We lazy people often use the index as the key.

Something like this:

But in the React documentation, they said this:

“We don’t recommend using indexes for keys if the order of items may change. This can negatively impact performance and may cause issues with component state.”

It’s always advisable to use a unique property as a key, or if your data doesn’t have any unique attributes, then you can think of using nanoid, which generates a unique key.

Our previous example can be rewritten like this:

UPDATE: According to the updated nanoid documentation it’s no longer recommended to use nanoid() for performance issues. So you really need to find a proper key for your list.

2. They Use Fragments Over Divs

We all know React works with a virtual DOM and compares it with the actual DOM to render. But if there are unnecessary nodes to compare, it’s not good for performance.

For example, if we want to render three components, we group them inside a div.

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 (18)

Write a response