ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
19 lines • 739 B
JavaScript
import * as React from 'react';
import { RecordContextProvider } from "./RecordContext.js";
/**
* Wrap children with a RecordContext provider only if the value is defined.
*
* Allows a component to work outside of a record context.
*
* @example
*
* import { OptionalRecordContextProvider, TextField } from 'react-admin';
*
* const RecordTitle = ({ record }) => (
* <OptionalRecordContextProvider value={record}>
* <TextField source="title" />
* </OptionalRecordContextProvider>
* );
*/
export const OptionalRecordContextProvider = ({ value, children, }) => value ? (React.createElement(RecordContextProvider, { value: value }, children)) : (children);
//# sourceMappingURL=OptionalRecordContextProvider.js.map