main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
746 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | var react_1 = require("react");
|
---|
4 | var DEFAULT_USE_TITLE_OPTIONS = {
|
---|
5 | restoreOnUnmount: false,
|
---|
6 | };
|
---|
7 | function useTitle(title, options) {
|
---|
8 | if (options === void 0) { options = DEFAULT_USE_TITLE_OPTIONS; }
|
---|
9 | var prevTitleRef = react_1.useRef(document.title);
|
---|
10 | if (document.title !== title)
|
---|
11 | document.title = title;
|
---|
12 | react_1.useEffect(function () {
|
---|
13 | if (options && options.restoreOnUnmount) {
|
---|
14 | return function () {
|
---|
15 | document.title = prevTitleRef.current;
|
---|
16 | };
|
---|
17 | }
|
---|
18 | else {
|
---|
19 | return;
|
---|
20 | }
|
---|
21 | }, []);
|
---|
22 | }
|
---|
23 | exports.default = typeof document !== 'undefined' ? useTitle : function (_title) { };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.