React: Busted Myths and How to avoid pitfalls 🔥

Apr 2, 2024Delving into common misconceptions and rigid beliefs — the so-called “cults”

react-myths-busted

In the world of software development, there are often strongly held beliefs and practices that become ingrained in certain communities. React, a popular JavaScript library for building user interfaces, is no exception.

In this post, we’ll delve into some common misconceptions and rigid beliefs — the so-called “cults” — that some React developers hold, and why they can actually hinder your ability to write good React code.


🧠 The Cult of the Never Spreaders

Belief: Spreading operators (...) should never be used in React because they are bad for performance.
Reality: Spreading is a common and necessary way to create new arrays or objects in React. Yes, it creates new references, but often that's exactly what you want to signal state changes to React.

✅ Verdict: 2 out of 5
Spreading can be misused, but it’s valid and even essential in most cases.


📦 The Cult Where Redux Is Mandatory

Belief: Every React application must use a state management library like Redux.
Reality: Modern React (with Hooks and Context) can handle most state management needs just fine. Redux is powerful for large, complex apps — but it's overkill for many use cases.

✅ Verdict: 3 out of 5
Redux has its place but isn't always necessary.


🏢 The Cult of Condo Components

Belief: Components should be nested inside other components to stay “organized.”
Reality: Inline component definitions inside other components can harm performance by causing unnecessary re-renders. Define components at the top level when possible.

❌ Verdict: 0 out of 5
Discouraged by React’s best practices and docs.


❌ The Cult of Anti-Memoization

Belief: useMemo and useCallback are bad for performance and should be avoided.
Reality: These hooks exist to optimize performance. While premature optimization is bad, avoiding these tools entirely can also lead to problems.

✅ Verdict: 0 out of 5
They’re powerful tools — use them when it makes sense.


🪞 The Cult That Wants Only a Single Render

Belief: Components should render only once.
Reality: React’s core strength is its ability to re-render efficiently when state or props change.

❌ Verdict: 0 out of 5
Trying to enforce single renders defeats the purpose of React’s reactivity.


🛠️ The Cult of Manual DOM Manipulation

Belief: It’s better to directly manipulate the DOM (e.g., getElementById) rather than rely on React.
Reality: React manages the DOM for you. Direct DOM manipulation can break React’s internal state and lead to bugs or performance issues.

❌ Verdict: 0 out of 5
Let React do its job.


🧬 The Cult of Class Component Hierarchies

Belief: Class components should inherit from each other like traditional OOP hierarchies.
Reality: React favors composition over inheritance. All components extend React.Component, but extending custom components is discouraged.

❌ Verdict: 0 out of 5
Composition is the React way.


🧘‍♂️ The Importance of Adaptability

These “cults” are rooted in an unhealthy mindset of rigidity. In software, adaptability is everything. React has evolved dramatically — from class components to hooks, from Redux to useReducer + Context — and so should we.

Instead of clinging to dogma, developers should understand React’s core principles:

  • Reusability
  • Declarative UIs
  • One-way data flow
  • Composition over inheritance

Avoid outdated or misunderstood practices. Instead, write code that is cleaner, faster, and easier to maintain.


💬 Final Thoughts

If this post helped you spot a belief you’ve been holding too tightly — that’s great! Growth begins with questioning assumptions.

React is flexible. Be like React.

If you’ve seen other “React cults” in the wild or have stories to share — I’d love to hear them! Drop a comment below. 👇

Happy coding! 🧑‍💻✨

© Rayan Fernandes. All Rights Reserved.