-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathCreateContext.tsx
35 lines (33 loc) · 974 Bytes
/
CreateContext.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { createContext } from 'react';
import { CreateControllerResult } from './useCreateController';
/**
* Context to store the result of the useCreateController() hook.
*
* Use the useCreateContext() hook to read the context. That's what the Create components do in react-admin.
*
* @example
*
* import { useCreateController, CreateContextProvider } from 'ra-core';
*
* const Create = props => {
* const controllerProps = useCreateController(props);
* return (
* <CreateContextProvider value={controllerProps}>
* ...
* </CreateContextProvider>
* );
* };
*/
export const CreateContext = createContext<CreateControllerResult>({
record: null,
defaultTitle: null,
isFetching: null,
isLoading: null,
redirect: null,
resource: null,
save: null,
saving: null,
registerMutationMiddleware: null,
unregisterMutationMiddleware: null,
});
CreateContext.displayName = 'CreateContext';