Do controlled and uncontrolled just mean stateless and stateful?

Question

In the context of this exercise, do controlled and uncontrolled just mean stateless and stateful?

Answer

No, controlled and uncontrolled cannot be used interchangeably with the terms stateless and stateful. Controlled and uncontrolled are always used in the context of React forms, which can be stateless or stateful. However, controlled and uncontrolled components are usually attributed with a stateless and a stateful nature, respectively.

A controlled component has its state controlled from outside. Because of this, controlled components are usually stateless as they do not store their own state and receive it from a parent component.

Uncontrolled components are essentially stateful, as they store and maintain their own internal state.

8 Likes

So in this case, the input form was uncontrolled and the element that displayed current user input was controlled?

1 Like

The input itself was changed from uncontrolled to controlled.

An input itself is uncontrolled, but when given a ‘value=’ attribute, the input itself then becomes controlled. Which means it stops tracking its own internal state in favor of an externally tracked state.

2 Likes