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
<ShowBase render={({ isPending, error, record }) => {
121
-
if (isPending) {
122
-
return<p>Loading...</p>;
123
-
}
124
-
125
-
if (error) {
126
-
return (
127
-
<p className="error">
128
-
{error.message}
129
-
</p>
130
-
);
131
-
}
132
-
return<p>{record.title}</p>;
133
-
}}/>
134
-
);
135
-
```
136
-
{% endraw %}
137
-
138
111
## `disableAuthentication`
139
112
140
113
By default, the `<ShowBase>` component will automatically redirect the user to the login page if the user is not authenticated. If you want to disable this behavior and allow anonymous access to a show page, set the `disableAuthentication` prop to `true`.
@@ -253,6 +226,33 @@ The default `onError` function is:
253
226
}
254
227
```
255
228
229
+
## `render`
230
+
231
+
Alternatively, you can pass a `render` function prop instead of children. This function will receive the `ShowContext` as argument.
<ShowBase render={({ isPending, error, record }) => {
239
+
if (isPending) {
240
+
return<p>Loading...</p>;
241
+
}
242
+
243
+
if (error) {
244
+
return (
245
+
<p className="error">
246
+
{error.message}
247
+
</p>
248
+
);
249
+
}
250
+
return<p>{record.title}</p>;
251
+
}}/>
252
+
);
253
+
```
254
+
{% endraw %}
255
+
256
256
## `resource`
257
257
258
258
By default, `<ShowBase>` operates on the current `ResourceContext` (defined at the routing level), so under the `/posts/1/show` path, the `resource` prop will be `posts`. You may want to force a different resource. In this case, pass a custom `resource` prop, and it will override the `ResourceContext` value.
0 commit comments