From f800c3ab924e3b9be7f708d1e99dd1eb342170c3 Mon Sep 17 00:00:00 2001 From: Ashley Lamont Date: Mon, 27 Nov 2023 16:49:26 +1100 Subject: [PATCH 1/2] Update examples in docs and add notes about resources plugin --- docs/README.md | 6 ++++-- docs/resources/concept.md | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 5e9700dc..f7bbf070 100644 --- a/docs/README.md +++ b/docs/README.md @@ -108,7 +108,7 @@ export const appRoutes = [ ### Use the Router -Now that you've set up your resources, components and configuration correctly, all you need to do is mount the [Router](api/components.md#router) in your react tree with a [`RouteComponent`](api/components.md#routecomponent) as a child. It will do the rest! +Now that you've set up your resources, components and configuration correctly, all you need to do is mount the [Router](api/components.md#router) with the [Resources Plugin](api/components?id=resources-plugin) in your react tree, and a [`RouteComponent`](api/components.md#routecomponent) as a child. It will do the rest! ```js import { @@ -116,12 +116,14 @@ import { RouteComponent, createBrowserHistory, } from 'react-resource-router'; +import {createResourcesPlugin} from "react-resource-router/resources"; import { appRoutes } from './routing/routes'; const history = createBrowserHistory(); +const resourcesPlugin = createResourcesPlugin({}); const App = () => ( - + ); diff --git a/docs/resources/concept.md b/docs/resources/concept.md index 18634f2a..eea11336 100644 --- a/docs/resources/concept.md +++ b/docs/resources/concept.md @@ -5,3 +5,5 @@ Router Resources are objects that are used by the router to fetch, cache and pro You can create these objects using the [`createResource`](./creation.md) function and then put them in the `resources` array on your route configuration object. Doing so means that each resources' data will be fetched as soon as the Router is mounted on initial page loads and on route transitions if the resources have expired. Since we recommend that your [`Router`](../api/components.md#router) sits as high up in your React tree as possible, it means that asynchronous requests for data are triggered as early as can be. This results in quicker meaningful render times. + +When using resources, you should initialise the resources plugin with [`createResourcesPlugin`](../api/components?id=resources-plugin), and ensure that this is loaded as a plugin when calling [`Router`](../api/components.md#router) in your app. \ No newline at end of file From 223feece8d67aa2ad4ed7f717459e26eb176be8e Mon Sep 17 00:00:00 2001 From: Shrey Sudhir Date: Wed, 28 Feb 2024 19:30:42 +1100 Subject: [PATCH 2/2] Update docs/README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index f7bbf070..34472a67 100644 --- a/docs/README.md +++ b/docs/README.md @@ -116,7 +116,7 @@ import { RouteComponent, createBrowserHistory, } from 'react-resource-router'; -import {createResourcesPlugin} from "react-resource-router/resources"; +import { createResourcesPlugin } from "react-resource-router/resources"; import { appRoutes } from './routing/routes'; const history = createBrowserHistory();