Skip to content

Use React Hooks where appropriate #2538

@swissspidy

Description

@swissspidy

In the latest version of Gutenberg, a bunch of handy React hooks have been added, most notably useSelect and useDispatch. (see documentation). It also exposes existing hooks like useState, for example.

Specifically for AMP Stories we have added many higher-order components that over time can make code quite hard to read. We also heavily leverage the pre-existing withSelect and withDispatch HOCs.

With React hooks we have the opportunity to greatly simplify many of our custom React components to make them easier to comprehend and maintain in the long term.

Note: withSelect internally already uses that new useSelect hook, so switching to hooks directly would remove an unnecessary layer in-between.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions