1
1
import * as React from 'react' ;
2
2
import { ReactElement } from 'react' ;
3
3
import PropTypes from 'prop-types' ;
4
- import {
5
- CreateContextProvider ,
6
- RaRecord ,
7
- ResourceContextProvider ,
8
- useCheckMinimumRequiredProps ,
9
- useCreateController ,
10
- } from 'ra-core' ;
4
+ import { RaRecord , useCheckMinimumRequiredProps } from 'ra-core' ;
11
5
12
6
import { CreateProps } from '../types' ;
13
7
import { CreateView } from './CreateView' ;
8
+ import { CreateBase } from 'ra-core' ;
14
9
15
10
/**
16
11
* Page component for the Create view
@@ -59,19 +54,30 @@ export const Create = <RecordType extends RaRecord = any>(
59
54
props : CreateProps < RecordType > & { children : ReactElement }
60
55
) : ReactElement => {
61
56
useCheckMinimumRequiredProps ( 'Create' , [ 'children' ] , props ) ;
62
- const controllerProps = useCreateController < RecordType > ( props ) ;
63
- const body = (
64
- < CreateContextProvider value = { controllerProps } >
65
- < CreateView { ...props } { ...controllerProps } />
66
- </ CreateContextProvider >
67
- ) ;
68
- return props . resource ? (
69
- // support resource override via props
70
- < ResourceContextProvider value = { props . resource } >
71
- { body }
72
- </ ResourceContextProvider >
73
- ) : (
74
- body
57
+ const {
58
+ resource,
59
+ record,
60
+ redirect,
61
+ transform,
62
+ mutationOptions,
63
+ disableAuthentication,
64
+ hasEdit,
65
+ hasShow,
66
+ ...rest
67
+ } = props ;
68
+ return (
69
+ < CreateBase
70
+ resource = { resource }
71
+ record = { record }
72
+ redirect = { redirect }
73
+ transform = { transform }
74
+ mutationOptions = { mutationOptions }
75
+ disableAuthentication = { disableAuthentication }
76
+ hasEdit = { hasEdit }
77
+ hasShow = { hasShow }
78
+ >
79
+ < CreateView { ...rest } />
80
+ </ CreateBase >
75
81
) ;
76
82
} ;
77
83
@@ -81,7 +87,6 @@ Create.propTypes = {
81
87
children : PropTypes . element ,
82
88
className : PropTypes . string ,
83
89
disableAuthentication : PropTypes . bool ,
84
- hasCreate : PropTypes . bool ,
85
90
hasEdit : PropTypes . bool ,
86
91
hasShow : PropTypes . bool ,
87
92
redirect : PropTypes . oneOfType ( [
@@ -92,7 +97,6 @@ Create.propTypes = {
92
97
resource : PropTypes . string ,
93
98
title : PropTypes . node ,
94
99
record : PropTypes . object ,
95
- hasList : PropTypes . bool ,
96
100
mutationOptions : PropTypes . object ,
97
101
transform : PropTypes . func ,
98
102
sx : PropTypes . any ,
0 commit comments