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';
42
42
*/
43
43
export const EditBase = < RecordType extends RaRecord = any , ErrorType = Error > ( {
44
44
children,
45
- render ,
45
+ disableAuthentication ,
46
46
loading,
47
47
offline,
48
+ render,
48
49
...props
49
50
} : EditBaseProps < RecordType , ErrorType > ) => {
50
51
const controllerProps = useEditController < RecordType , ErrorType > ( props ) ;
@@ -62,29 +63,26 @@ export const EditBase = <RecordType extends RaRecord = any, ErrorType = Error>({
62
63
63
64
const { isPaused, record } = controllerProps ;
64
65
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
+
65
75
return (
66
76
// We pass props.resource here as we don't need to create a new ResourceContext if the props is not provided
67
77
< OptionalResourceContextProvider value = { props . resource } >
68
78
< 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 }
88
86
</ EditContextProvider >
89
87
</ OptionalResourceContextProvider >
90
88
) ;
You can’t perform that action at this time.
0 commit comments