Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix examples in docs and add notes about resources plugin #219

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,22 @@ 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 {
Router,
RouteComponent,
createBrowserHistory,
} from 'react-resource-router';
import {createResourcesPlugin} from "react-resource-router/resources";
spanishpear marked this conversation as resolved.
Show resolved Hide resolved
import { appRoutes } from './routing/routes';

const history = createBrowserHistory();
const resourcesPlugin = createResourcesPlugin({});

const App = () => (
<Router routes={appRoutes} history={history}>
<Router routes={appRoutes} history={history} plugins={[resourcesPlugin]}>
<RouteComponent />
</Router>
);
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/concept.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.