Andrew's Digital Garden

Imperative vs declarative React

React is declarative. You describe the output through JSX and React takes care of implementing and rendering the desired result.

However, that doesn't mean that all code is declarative.

Conceptually, React components have always been closer to functions. Hooks embrace functions, but without sacrificing the practical spirit of React. Hooks provide access to imperative escape hatches and don’t require you to learn complex functional or reactive programming techniques.

Using the hook in a component is often still declarative, but the hook itself is usually written imperatively.

[[20211115081803-imperative-vs-declarative]]

[[react]] [[reactapi]]

Imperative vs declarative React