ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
28 lines • 1.02 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.useBasename = void 0;
var react_1 = require("react");
var BasenameContext_1 = require("./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 react-admin components that
* contain a link, and requires that the basename is set via the
* `<BasenameContextProvider>` component (or via the `<Admin>` component,
* which calls BasenameContextProvider internally).
*
* @see BasenameContextProvider
*
* @example
* import { useBasename } from 'react-admin';
*
* const ArticleLink = ({ title, id }) => {
* const basename = useBasename();
* return <a href={`${basename}/articles/${id}`}>{title}</a>;
* };
*/
var useBasename = function () { return (0, react_1.useContext)(BasenameContext_1.BasenameContext); };
exports.useBasename = useBasename;
//# sourceMappingURL=useBasename.js.map
;