import { useContext } from 'react'; import { BasenameContext } from './BasenameContext'; /** * Get the string to append to all links to the admin app. * * Useful when the app is mounted on a sub path, e.g. '/admin'. * * This hook is used internally by all mv-tmp components that * contain a link, and requires that the basename is set via the * `` component (or via the `` component, * which calls BasenameContextProvider internally). * * @see BasenameContextProvider * * @example * import { useBasename } from 'mv-tmp'; * * const ArticleLink = ({ title, id }) => { * const basename = useBasename(); * return {title}; * }; */ export const useBasename = () => useContext(BasenameContext);