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