import * as React from 'react'; import { ReactNode } from 'react'; import { useCreateController, CreateControllerProps, } from './useCreateController'; import { CreateContextProvider } from './CreateContextProvider'; import { RaRecord } from '../../types'; import { ResourceContextProvider } from '../../core'; /** * Call useCreateController and put the value in a CreateContext * * Base class for components, without UI. * * Accepts any props accepted by useCreateController: * - id: The record identifier * - resource: The resource * * @example // Custom edit layout * * const PostCreate = props => ( * * * * * ... * * * * Create instructions... * * *
* Post related links... *
*
* ); */ export const CreateBase = ({ children, ...props }: CreateControllerProps & { children: ReactNode }) => { const controllerProps = useCreateController(props); const body = ( {children} ); return props.resource ? ( // support resource override via props {body} ) : ( body ); };