-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
/
EditContext.tsx
37 lines (35 loc) · 987 Bytes
/
EditContext.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
36
37
import { createContext } from 'react';
import { EditControllerResult } from './useEditController';
/**
* Context to store the result of the useEditController() hook.
*
* Use the useEditContext() hook to read the context. That's what the Edit components do in react-admin.
*
* @example
*
* import { useEditController, EditContextProvider } from 'ra-core';
*
* const Edit = props => {
* const controllerProps = useEditController(props);
* return (
* <EditContextProvider value={controllerProps}>
* ...
* </EditContextProvider>
* );
* };
*/
export const EditContext = createContext<EditControllerResult>({
record: null,
defaultTitle: null,
isFetching: null,
isLoading: null,
mutationMode: null,
redirect: null,
refetch: null,
resource: null,
save: null,
saving: null,
registerMutationMiddleware: null,
unregisterMutationMiddleware: null,
});
EditContext.displayName = 'EditContext';