You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@
7
7
8
8
Apply the `useRelay` router middleware, pass in a Relay environment to `<Router>`, then define Relay queries and render callbacks for each of your routes:
Apply the `useRelay` router middleware, and pass in a Relay environment to the `<Router>`:
69
69
70
-
```jsx
70
+
```js
71
71
importuseRelayfrom'react-router-relay';
72
72
73
73
/* ... */
@@ -89,7 +89,7 @@ ReactDOM.render(
89
89
90
90
For each of your routes that requires data from Relay, define a `queries` prop on the `<Route>`. These should be just like the queries on a Relay query config:
91
91
92
-
```jsx
92
+
```js
93
93
constViewerQueries= {
94
94
viewer: () =>Relay.QL`query { viewer }`
95
95
};
@@ -109,7 +109,7 @@ If your route doesn't have any dependencies on Relay data, just don't declare `q
109
109
110
110
If your route's Relay data dependencies are a function of the location or of the parameters, you can define a `getQueries` function on your route that returns the computed queries as a function of the current router state:
For routes with named components, define `queries` as an object with the queries for each component by name:
209
209
210
-
```jsx
210
+
```js
211
211
<Route
212
212
components={{ foo: FooComponent, bar: BarComponent }}
213
213
queries={{ foo: FooQueries, bar: BarQueries }}
@@ -218,7 +218,7 @@ For routes with named components, define `queries` as an object with the queries
218
218
219
219
You can pass in a custom `render` callback to your routes:
220
220
221
-
```jsx
221
+
```js
222
222
<Route
223
223
component={WidgetList}
224
224
queries={ViewerQueries}
@@ -232,7 +232,7 @@ While transitioning, the ready state properties (`done`, `error`, `retry`, `stal
232
232
233
233
The argument object to the render callback includes two extra properties: `routerProps` and `element`. `routerProps` contains the props from the router, and unlike `props`, will be populated regardless of the Relay ready state. `routerProps` can be used to render child routes while the data for the parent route are still loading, or to otherwise use information from the router to control rendering before the Relay data are available. `element` contains the base route element without the props from Relay, and can be used to render the route component when the route uses a dynamic component, or when using other router middlewares that may wrap the route component:
234
234
235
-
```jsx
235
+
```js
236
236
({ props, routerProps, element }) => {
237
237
if (!props) {
238
238
return<Loading {...routerProps} />;
@@ -244,7 +244,7 @@ The argument object to the render callback includes two extra properties: `route
244
244
245
245
When using named components, you can define these on a per-component basis, optionally omitting the callback for components that do not need a custom render callback:
246
246
247
-
```jsx
247
+
```js
248
248
<Route
249
249
components={{ foo: FooComponent, bar: BarComponent }}
250
250
queries={{ foo: FooQueries, bar: BarQueries }}
@@ -256,7 +256,7 @@ When using named components, you can define these on a per-component basis, opti
256
256
257
257
We pass through additional props on `<Router>` or the generated router context to the underlying `Relay.Renderer`. You can use this to control props like `forceFetch` on the `Relay.Renderer`:
0 commit comments