DEV Community

Cover image for React - Stateless vs Stateful Components

React - Stateless vs Stateful Components

Matthew Carpenter on December 11, 2018

Prerequisite - This tutorial is intended for beginners who have started learning React and need a better overview of components. Componen...
Collapse
 
andywer profile image
Andy Wermke

Thanks for sharing. Unfortunately it's not completely true anymore.

Since React hooks are now a thing, functional components can be stateful and have a lifecycle just as well. Furthermore class-based components can also be stateless (if all they have is a render method, but of course it would only be reasonable to turn them into a functional component then).

The post is rather describing class-based components vs functional components.

There is nothing wrong about describing that, but the concept class=stateful and function=stateless is now a thing of the past ;)

Collapse
 
dance2die profile image
Sung M. Kim

Thanks Matthew.

Understanding the distinction in this article is helpful for new React beginners because having states unnecessarily spread out everywhere can cause components to have many sources of truth thus out of sync ♻ (e.g. initializing a component state to that of a prop).