Skip to content

Commit

Permalink
grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryGonchar authored May 27, 2024
1 parent 1850152 commit 00d66d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/resources/creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const userProfileResource = createResource({
| Property | type | Description |
| --------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `type` | `string` | Used as a namespace for this resource. Each resource should have a unique type |
| `getKey` | `(routerContext, customContext) => string` | The return value of this function is used to identify this resource within the `type` namespace. The function itself is supplied with `routerContext` and `customContext` so that the composition of keys can use this data if required. `customContext` comes from the top level Router component, therefore changing it will cause a re-render of almost everything in your React app. You may want to pass a custom `routerContext` instead, to do this - see the ["Accessing resource state for another route or url"](https://atlassian-labs.github.io/react-resource-router/#/resources/usage?id=accessing-resource-state-for-another-route-or-url) section. The router will fetch and cache data for that route then. |
| `getData` | `(routerExtendedContext, customContext) => Promise<any>` | This function is used to load the data for the resource. it is called when initial fetch or `refresh()` is caleld on the resourse. The function should return a promise and resolve with the resource data object. NOTE: You may not use `getData` and `getDataLoader` on the same resource. |
| `getKey` | `(routerContext, customContext) => string` | The return value of this function is used to identify this resource within the `type` namespace. The function itself is supplied with `routerContext` and `customContext` so that the composition of keys can use this data if required. `customContext` comes from the top level Router component, therefore changing it will cause a re-render of almost everything in your React app. You may want to pass a custom `routerContext` instead. How to do this - see the ["Accessing resource state for another route or url"](https://atlassian-labs.github.io/react-resource-router/#/resources/usage?id=accessing-resource-state-for-another-route-or-url) section. The router will fetch and cache data for that route then. |
| `getData` | `(routerExtendedContext, customContext) => Promise<any>` | This function is used to load the data for the resource. It is called when initial fetch or `refresh()` is called on the resourse. The function should return a promise and resolve with the resource data object. NOTE: You may not use `getData` and `getDataLoader` on the same resource. |
| `maxAge` | `number` | How long (in milliseconds) the resource should be kept in the router before a fresh resource is retrieved. Note: resources are only refreshed on route _change_. The router does not poll or update resources in the background. Navigation within the same route, e.g. query param change, will not trigger a refresh of resources. |
| `maxCache` | `number` | How many resources can be kept in the router for a particular `type`. Once the threshold limit is reached, a **Least Recently** used resource gets deleted, making space for the new requested resource of the same type. |
| `getDataLoader` | `() => Promise<{default: getData}>` | Optional property that enables neater code splitting. See more below. NOTE: You may not use `getData` and `getDataLoader` on the same resource
Expand Down

0 comments on commit 00d66d6

Please sign in to comment.