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