useTitle
Set document title.
API
function useTitle(title: string | null, options?: { restore?: boolean }): void;
Params:
title
: Required document title. If it isnull
, do nothing.options
: Options object.options.restore
: Restore old title on the component unmount.
Example
import React, { useState } from "react";
import { useTitle } from "@lilib/hooks";
function Example() {
const [title, setTitle] = useState("");
useTitle(title, { restore: true });
return (
<input
placeholder="Enter title"
value={title}
onChange={(event) => {
setTitle(event.target.value);
}}
/>
);
}
export default Example;