React: Busted Myths and How to avoid pitfalls

Rayan Fernandes
3 min readApr 2, 2024
React.js Myth Busted

In the world of software development, there are often strongly held beliefs and practices that can become ingrained in certain communities. React, a popular JavaScript library for building user interfaces, is no exception. In this blog post, we’ll delve into some of the common misconceptions and rigid beliefs that some React developers hold, and why they can hinder your ability to write good React code.

Breaking Down the React Cult Controversies

I have identified several areas where React developers may fall prey to these “cults”:

  1. 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 way to create new arrays or objects in React. While it does create new references, this is often necessary to signal to React that the data has changed.
  • Verdict: 2 out of 5. Spreading can be misused, but it’s a valid technique in most cases.

2. The cult where Redux is Mandatory

  • Belief: Every React application needs a state management library like Redux.
  • Reality: React hooks, Context API, and other built-in features can handle state management for many applications. Redux is a powerful tool, but it can also add complexity.
  • Verdict: 3 out of 5. Redux is a good choice for complex applications, but not always necessary.

3. The Cult of Condo Components

  • Belief: Components should be nested within other components to promote code organization.
  • Reality: Nesting components can make it difficult for React to optimize re-renders. Components should ideally be defined at the top level.
  • Verdict: 0 out of 5. Nested components are specifically discouraged in React documentation.

4. The Cult of Anti-Memoization

  • Belief: React’s useMemo and useCallback hooks are bad for performance and should be avoided.
  • Reality: These hooks can be helpful for performance optimization by preventing unnecessary re-computations.
  • Verdict: 0 out of 5. These hooks are valuable tools when used correctly.

5. The Cult that wants only Single Render

  • Belief: Components should only render once.
  • Reality: Components are designed to render whenever their data changes. Re-rendering is a core concept in React.
  • Verdict: 0 out of 5. Enforcing a single render goes against the core principles of React.

6. The Cult of Manual DOM Manipulation

  • Belief: It’s better to directly manipulate the DOM using methods like getElementById instead of relying on React's built-in mechanisms.
  • Reality: React is designed to manage the DOM efficiently. Directly manipulating the DOM can lead to inconsistencies and performance issues.
  • Verdict: 0 out of 5. Let React handle the DOM.

7. The Cult of Class Component Hierarchies

  • Belief: Class components should inherit from each other to create a hierarchy, similar to other frameworks.
  • Reality: React components are all subclasses of the base React.Component class. Inheriting from custom class hierarchies is discouraged.
  • Verdict: 0 out of 5. React uses composition rather than inheritance for component relationships.

The Importance of Adaptability

These cults stem from an unhealthy engineering mindset. Developers should avoid rigid beliefs and instead embrace adaptability and a willingness to learn new patterns. The key takeaway is to understand the core principles of React and avoid following outdated or misunderstood practices.

By shedding light on these common misconceptions, I encourage React developers to approach their work with a more critical and open mind. This will ultimately lead to writing cleaner, more efficient, and more maintainable React code.

I hope this blog post was helpful! If you have any questions or comments, feel free to leave them below.

--

--