react-use/src/useTitle.ts
2019-11-06 15:15:50 +03:00

12 lines
236 B
TypeScript

import { useRef } from 'react';
function useTitle(title: string) {
const t = useRef<string>();
if (t.current !== title) {
document.title = t.current = title;
}
}
export default document ? useTitle : (_title: string) => {};