Code faster with React using these techniques

Learn how to code faster with React thanks to simple but effective techniques used by experienced developers.
•
Updated on August 14, 2026
•
4 min read
Believemy logo

React has truly become an essential tool for front-end developers. However, there is a real difference between those who use React and those who truly understand it: execution speed and code readability are two crucial skills for any experienced developer.

If you want to optimize your development time and write clean code, these few techniques can help you save precious time. 😉

1. Use Ternary Conditions with &&

Using ternary conditions is already a good first approach with React! You can indeed condense your code to make it clearer.

However, it is not uncommon to see this type of ternary condition among beginner developers:

JSX
{
    isLoggedIn ? <LogoutButton /> : null
}

Here's what you should do:

JSX
{
    isLoggedIn && <LogoutButton />
}
Question

Wait, what just happened? 😳

Here, we simply used &&. It's a shortcut that tells React: if my condition is validated, then display what's on the right. Otherwise, do nothing.

2. Use Destructuring Assignment

Destructuring assignment is very important with React. It improves code clarity and reduces its length, which facilitates good reading.

Good to know

When we talk about destructuring assignment, we're actually talking about directly extracting values from arrays or objects.

Here's what a junior developer's code would do:

JSX
const value = this.props.value;
const other = this.props.other;
const again = this.props.again;

Here's what you should do instead as an experienced developer:

JSX
const { value, other, again } = this.props

Much simpler! 👀

3. Use React Fragments Properly

When you want to return multiple elements in a React component without encapsulating them in a div, you can use Fragments.

Good to know

A Fragment, also called a React Fragment, is a component used only to group multiple child elements without adding an additional node to the DOM (meaning another division).

This helps keep the DOM clean, but you can go even faster by using the shorthand version of Fragments: <> </>.

Here's what you should not do:

JSX
<React.Fragment>
    <Component />
    <Component />
</React.Fragment>

Here's what you should prefer:

JSX
<>
    <Component />
    <Component />
</>

It's cleaner! ✨

4. Use the Spread Operator

The spread operator (...) is extremely useful for copying or extending objects and arrays.

Good to know

The spread operator (...) is a JavaScript feature introduced with ES6 that allows us to unfold (or "spread") the elements of an array or object into another array or object. You'll quickly understand with our little example.

Don't do this anymore:

JSX
<Component
    propA={props.propA}
    propB={props.propB}
/>

But prefer this way:

JSX
<Component {...props} />

Here, we're passing our props to our component dynamically: no need to bother passing each property one by one. When we add a new property to the parent component, it will be dynamically brought to the child component.

5. Use Optional Chaining

It is extremely important to use optional chaining with React. But you first need to know how to use it.

Good to know

Optional chaining (?.) is a new JavaScript feature that allows accessing deeply nested properties without having to check at each level whether the object or property exists. It's very useful for avoiding "cannot read property of undefined" type errors.

For example, here's what you should not do:

JSX
const name = props.user && props.user.name;

Use optional chaining:

JSX
const name = props.user?.name;

The idea is to ask React to check if the user value exists, otherwise return null.

The Importance of Being Well Trained

Too often, junior developers graduate from training that teaches them React with bad techniques and conventions. Sometimes, they learn React on older versions (see one of our articles that talks about this). This means that in the end, you'll end up with skills that no one will want, or with ways of creating your projects that will make your life very complicated throughout your career.

Question

OK, but how do we avoid this?

By choosing a very good, comprehensive training.

It's obvious, you'll tell me, and yet, how many actually do it?

If you enjoyed this article, know that you're not at the end of your surprises. If you want to avoid wasting your time on things that aren't worth it, go check out our React training.

It will be the best decision of your day. 😇

Category: Developers

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.

Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Read next

Creating a markdown previewer with React

Creating a real markdown previewer with React, and above all, doing it correctly, requires real concentration! Fortunately, with a little help anyone can do it. Here are a few tips for creating your own markdown previewer!

December 9, 2024

Why you should learn React in 2025: all the benefits!

Explore why React remains a must-have choice in 2025 for developers. Discover its advantages, the evolution of its features and why the market continues to prefer it.

December 6, 2024

What's new in React 19

React 19 has just been announced by the Meta team. Powerful new features have been introduced almost two years after the release of React 18.3. Let's find out what's new with React 19.

December 5, 2024

How to use Server Actions with NextJS

Discover why and how NextJS Server Actions improve performance on both Client Components and Server Components, and learn how to use them in your projects.

December 9, 2024

Respecting SOLID principles with React

The SOLID principles are a set of five fundamental programming concepts. They are mostly applied in OOP (Object-Oriented Programming). They can also be applied elsewhere. They are indispensable in software architecture. To present these principles, I've chosen to use Javascript rather than Typescript, so as not to weigh down the examples. We're going to apply these principles to a simple "Todo List".

December 11, 2024

How to use React's useEffect and useRef hooks?

Discover the best practices to adopt with useEffect and useRef, what they're for and how to use them in the right way.

December 11, 2024

Class-based component VS Functional Component with React

Have you always wondered about the difference between a component using a class and a component in the form of a function with React? Then this article is for you!

December 9, 2024

All about the new React Hook: useOptimistic

Discover useOptimistic, the React hook that makes your interfaces more responsive with instant updates. Streamline your user experience and simplify error handling. Slug: all about the new-hook-react-useoptimistic

December 9, 2024

Become the solopreneur you dream of being.

First project, career change, business launch: access our courses, practice on real-world cases, and move forward with clear guidance.