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.
Files changed (2) hide show
  1. package/README.md +13 -5
  2. 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
- const UserProfile = () => {
230
- const user = useLoaderState();
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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clear-react-router",
3
- "version": "1.3.9",
3
+ "version": "1.4.0",
4
4
  "description": "A lightweight, type-safe routing library for React applications",
5
5
  "author": "Andrew Bubnov",
6
6
  "scripts": {