ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
23 lines (20 loc) • 585 B
text/typescript
import { createContext } from 'react';
/**
* Context to store the current resource name.
*
* Use the useResource() hook to read the context. That's what most components do in react-admin.
*
* @example
*
* import { useResourceContext, useTranslate } from 'ra-core';
*
* const MyCustomEditTitle = props => {
* const name = useResourceContext(props);
*
* return (
* <h1>{translate(`${name}.name`)}</h1>
* );
* };
*/
export const ResourceContext = createContext<ResourceContextValue>(undefined);
export type ResourceContextValue = string | undefined;