UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

26 lines (22 loc) 696 B
import { createContext, useContext } from 'react'; export const HasDashboardContext = createContext<boolean>(false); export const HasDashboardContextProvider = HasDashboardContext.Provider; /** * Returns true if the app has a dashboard defined at the <Admin> level. * * @private * @example * import { useHasDashboard } from 'react-admin'; * * const MyMenu = () => { * const hasDashboard = useHasDashboard(); * return ( * <Menu> * {hasDashboard && <DashboardMenuItem />} * <MenuItemLink to="/posts" /> * <MenuItemLink to="/comments" /> * </Menu> * ); * } */ export const useHasDashboard = () => useContext(HasDashboardContext);