opendash
Version:
open.DASH data visualization framework
17 lines • 494 B
JavaScript
import * as React from "react";
import { useHref } from "..";
export function usePath() {
var href = useHref();
var _a = React.useState(hrefToPath(href)), path = _a[0], setPath = _a[1];
React.useEffect(function () {
var nextPath = hrefToPath(href);
if (path !== nextPath) {
setPath(nextPath);
}
}, [href]);
return path;
}
function hrefToPath(href) {
return new URL(href).pathname;
}
//# sourceMappingURL=usePath.js.map