alleyinteractive / alleyinteractive/alley-scripts

Block Editor Tools: `Suspense` support

Offen
#457 9 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
gutenberg javascript Package: block-editor-tools
Vorherrschende Sprache
TypeScript
Sterne
10
Forks
3
Ø Merge
4 T. 22 Std.
Gemergte PRs (30 T.)
2

Beschreibung

### Description

I just realized that none of the hooks, https://github.com/alleyinteractive/alley-scripts/tree/main/packages/block-editor-tools/src/hooks, have support for getting the status of a selector so that a developer can check if a resolver has finished its job.

A task that's particularly useful in scenarios where you need to know if data has been loaded or not.

This would involve a breaking change release, since the returned value of the hooks would be different.

----

For example:

```jsx
const MyBlock = ({
postID,
}) => {
const post = usePost(postID, postType);

// has the resolver finished getting the post?
// What should the component do in the meantime?
if (post) {
...
}
};
```

More: https://redux.js.org/usage/deriving-data-selectors

## Acceptance Criteria

- Add "Suspense" versions to hooks that would benefit from them (e.g., ones that use `useSelect`, like `usePost`). An example of this would be a hook like `useSuspensePost` that is a Suspense-enabled version of `usePost`. Under the hood, it could use `useSuspenseSelect` instead of `useSelect`.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.