import * as React from 'react';
import { ReactNode } from 'react';
import { useRecordContext } from './useRecordContext';
/**
* Render prop version of useRecordContext
*
* @example
* const BookShow = () => (
*
*
* {record.title}} />
*
*
* );
*/
export const WithRecord = = any>({
render,
empty = null,
}: WithRecordProps) => {
const record = useRecordContext();
return record ? <>{render(record)}> : empty;
};
export interface WithRecordProps = any> {
render: (record: RecordType) => ReactNode;
empty?: ReactNode;
label?: string;
}