I love the simplicity of React's reuse model


I love the simplicity of React's reuse model.

Repeating JSX? Create a component.
Repeating logic? Create a hook.

I can compose these simple building blocks in infinite ways.
Example: I just created a dialog. At first, I embedded logic in the dialog. Then I realized some sites needed different logic.

So I extracted the logic to a hook.

Now the dialog's JSX can be reused via a component.

And the dialog's logic can be consumed via a hook.

View original on X