useFavicon
Set document favicon.
API
function useFavicon(
href: string | null,
options?: { mime?: string; restore?: boolean }
): void;
Params:
href
: Required favicon url. If it isnull
, do nothing.options
: Options object.options.mime
: Specify the MIME type. Get automatically according to thehref
extname (support.png
,.gif
and.ico
).options.restore
: Restore old favicon on the component unmount.
Example
import React from "react";
import { useFavicon } from "@lilib/hooks";
function Example() {
useFavicon("https://example.com/favicon.ico", { restore: true });
...
}