Download react-use/src/useFavicon.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 409 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/src/useFavicon.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/src/useFavicon.ts
-
curl -L -o useFavicon.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/src/useFavicon.ts
409 Bytes
| import { useEffect } from 'react'; | |
| const useFavicon = (href: string) => { | |
| useEffect(() => { | |
| const link: HTMLLinkElement = | |
| document.querySelector("link[rel*='icon']") || document.createElement('link'); | |
| link.type = 'image/x-icon'; | |
| link.rel = 'shortcut icon'; | |
| link.href = href; | |
| document.getElementsByTagName('head')[0].appendChild(link); | |
| }, [href]); | |
| }; | |
| export default useFavicon; | |