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