one
Version:
One is a new React Framework that makes Vite serve both native and web.
27 lines (26 loc) • 679 B
JavaScript
import * as React from "react";
function useDocumentTitle(ref, {
enabled = !0,
formatter = (options, route) => options?.title ?? route?.name
} = {}) {
React.useEffect(() => {
if (!enabled)
return;
const navigation = ref.current;
if (navigation) {
const title = formatter(
navigation.getCurrentOptions(),
navigation.getCurrentRoute()
);
document.title = title;
}
return navigation?.addListener("options", (e) => {
const title = formatter(e.data.options, navigation?.getCurrentRoute());
document.title = title;
});
});
}
export {
useDocumentTitle
};
//# sourceMappingURL=useDocumentTitle.js.map