File tree Expand file tree Collapse file tree 1 file changed +18
-20
lines changed
packages/ra-core/src/controller/show Expand file tree Collapse file tree 1 file changed +18
-20
lines changed Original file line number Diff line number Diff line change @@ -41,9 +41,10 @@ import { useIsAuthPending } from '../../auth';
4141 */
4242export const ShowBase = < RecordType extends RaRecord = any > ( {
4343 children,
44- render ,
44+ disableAuthentication ,
4545 loading,
4646 offline,
47+ render,
4748 ...props
4849} : ShowBaseProps < RecordType > ) => {
4950 const controllerProps = useShowController < RecordType > ( props ) ;
@@ -61,29 +62,26 @@ export const ShowBase = <RecordType extends RaRecord = any>({
6162
6263 const { isPaused, record } = controllerProps ;
6364
65+ const shouldRenderLoading =
66+ isAuthPending &&
67+ ! disableAuthentication &&
68+ loading !== false &&
69+ loading !== undefined ;
70+
71+ const shouldRenderOffline =
72+ isPaused && ! record && offline !== false && offline !== undefined ;
73+
6474 return (
6575 // We pass props.resource here as we don't need to create a new ResourceContext if the props is not provided
6676 < OptionalResourceContextProvider value = { props . resource } >
6777 < ShowContextProvider value = { controllerProps } >
68- { ( ( ) => {
69- if (
70- isAuthPending &&
71- ! props . disableAuthentication &&
72- loading !== false &&
73- loading !== undefined
74- ) {
75- return loading ;
76- }
77- if (
78- isPaused &&
79- ! record &&
80- offline !== false &&
81- offline !== undefined
82- ) {
83- return offline ;
84- }
85- return render ? render ( controllerProps ) : children ;
86- } ) ( ) }
78+ { shouldRenderLoading
79+ ? loading
80+ : shouldRenderOffline
81+ ? offline
82+ : render
83+ ? render ( controllerProps )
84+ : children }
8785 </ ShowContextProvider >
8886 </ OptionalResourceContextProvider >
8987 ) ;
You can’t perform that action at this time.
0 commit comments