24 lines
746 B
JavaScript
24 lines
746 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var react_1 = require("react");
|
|
var DEFAULT_USE_TITLE_OPTIONS = {
|
|
restoreOnUnmount: false,
|
|
};
|
|
function useTitle(title, options) {
|
|
if (options === void 0) { options = DEFAULT_USE_TITLE_OPTIONS; }
|
|
var prevTitleRef = react_1.useRef(document.title);
|
|
if (document.title !== title)
|
|
document.title = title;
|
|
react_1.useEffect(function () {
|
|
if (options && options.restoreOnUnmount) {
|
|
return function () {
|
|
document.title = prevTitleRef.current;
|
|
};
|
|
}
|
|
else {
|
|
return;
|
|
}
|
|
}, []);
|
|
}
|
|
exports.default = typeof document !== 'undefined' ? useTitle : function (_title) { };
|