UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

34 lines 1.21 kB
import * as React from 'react'; import { RecordContextProvider } from "../record/RecordContext.js"; import { CreateContext } from "./CreateContext.js"; import { SaveContextProvider, usePickSaveContext } from "../saveContext/index.js"; /** * Create a Create Context. * * @example * * const MyCreate = (props) => { * const controllerProps = useCreateController(props); * return ( * <CreateContextProvider value={controllerProps}> * <MyCreateView> * </CreateContextProvider> * ); * }; * * const MyCreateView = () => { * const record = useRecordContext(); * // or, to rerender only when the save operation change but not data * const { saving } = useCreateContext(); * } * * @see CreateContext * @see RecordContext */ export const CreateContextProvider = ({ children, value, }) => (React.createElement(CreateContext.Provider, { value: value }, React.createElement(SaveContextProvider, { value: { ...usePickSaveContext(value), mutationMode: 'pessimistic', } }, React.createElement(RecordContextProvider, { value: value && value.record }, children)))); //# sourceMappingURL=CreateContextProvider.js.map