You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hooks above will provide you all fields matching selectors that bundles are capable of.
47
+
48
+
## Using with Suspense and Error Boundaries
49
+
50
+
**Warning: using Suspense or Error boundaries assumes throwing things. Make sure these hooks are the only ones or the last ones you use within a single component in order to respect [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html).**
51
+
52
+
Both hooks receive one last `settings` parameter which can have following fields (all disabled by default):
53
+
54
+
-`throwErrors` – if truthy, will throw an error for you when there is an error and there is no past data to show. Setting it to `"always"` will always throw if there is an active error.
55
+
-`throwPromises` – if truthy, will throw a promise when item is loading and there is no data to show. Setting it to "always" will always throw a promise if item is loading or refreshing.
56
+
-`eagerFetch` – see below
57
+
58
+
##### Using errors
59
+
60
+
Error boundary can implement a proper "wait-retry" mechanism. Instead of throwing original error, hook will throw an instance of `AsyncResourceError` which will have following properties:
61
+
62
+
-`resourceName` – which should be self-explanatory
63
+
-`originalError` – an instance of original exception that bundle's `getPromise` rejected with
64
+
-`permanent` – translated from original error
65
+
-`retryAt` – a timestamp at which bundle will attempt next retry for this item
66
+
-`retry` – method that can force-trigger a fetch on an item
67
+
68
+
##### Enabling default behavior
69
+
70
+
Default values for `throwErrors` and `throwPromises` can be overridden per hook. If you prefer to always use error boundaries and/or suspenses, you can do the following early before any react code is on:
When setting `eagerFetch` to a truthy value in hooks `settings` parameter, hook will fire an effect which would trigger fetch actions on the item when it is pending for fetch.
82
+
83
+
It is on-purpose impossible to override with setting with a default.
0 commit comments