clear-react-router 1.3.9 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -224,13 +224,21 @@ const { pathname, search, state } = useLocation();
|
|
|
224
224
|
|
|
225
225
|
### `useLoaderState()`
|
|
226
226
|
|
|
227
|
-
Returns the cached data loaded by the current route's `loader`. Data is automatically cached and reused when navigating back to the same route.
|
|
227
|
+
Returns the cached data loaded by the current route's `loader`, along with any errors from `loader` or `beforeLoad`. Data is automatically cached and reused when navigating back to the same route.
|
|
228
|
+
|
|
229
|
+
**Returns:**
|
|
230
|
+
|
|
231
|
+
| Property | Type | Description |
|
|
232
|
+
|----------|------|-------------|
|
|
233
|
+
| `data` | `unknown` | The data returned from the route's `loader` |
|
|
234
|
+
| `loaderError` | `Error \| null` | Error from the `loader` (if any) |
|
|
235
|
+
| `beforeLoadError` | `Error \| null` | Error from the `beforeLoad` hook (if any) |
|
|
236
|
+
|
|
228
237
|
```
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
return <div>{user.name}</div>;
|
|
232
|
-
}
|
|
238
|
+
function UserProfile() {
|
|
239
|
+
const { data, loaderError, beforeLoadError } = useLoaderState();
|
|
233
240
|
```
|
|
241
|
+
|
|
234
242
|
### Caching behavior:
|
|
235
243
|
- The loader result is cached and reused when navigating back to the same route (e.g., from /user/123 back to /user/456 it will be a new request because different params, but from /user/456 to /user/456 — cache hit).
|
|
236
244
|
- Use staleTime in route config to control how long cache is considered fresh:
|