@rehooks/document-title
Advanced tools
Comparing version 1.0.1 to 1.0.2
interface DocumentTitle {} | ||
export default function useDocumentTitle(title: string): DocumentTitle; | ||
export default function useDocumentTitle(title: string, retainOnUnmount?: boolean): DocumentTitle; |
16
index.js
'use strict'; | ||
let { useEffect } = require('react'); | ||
let { useRef, useEffect } = require('react'); | ||
function useDocumentTitle(title) { | ||
function useDocumentTitle(title, retainOnUnmount = false) { | ||
const defaultTitle = useRef(document.title); | ||
useEffect(() => { | ||
document.title = title; | ||
}, [title]) | ||
}, [title]); | ||
useEffect(() => { | ||
return () => { | ||
if (!retainOnUnmount) { | ||
document.title = defaultTitle.current; | ||
} | ||
}; | ||
}, []); | ||
} | ||
module.exports = useDocumentTitle; |
{ | ||
"name": "@rehooks/document-title", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "React hook for updating document-title", | ||
@@ -21,15 +21,12 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "ava test.js", | ||
"test": "echo 'done!'", | ||
"example": "parcel example.html" | ||
}, | ||
"dependencies": { | ||
"react": "^16.8.3" | ||
"react": "^16.13.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.2.1", | ||
"browser-env": "^3.2.6", | ||
"parcel": "^1.11.0", | ||
"raf": "^3.4.0", | ||
"react-dom": "^16.8.3", | ||
"react-test-renderer": "^16.8.3" | ||
"parcel": "^1.12.4", | ||
"react-dom": "^16.13.1", | ||
"react-test-renderer": "^16.13.1" | ||
}, | ||
@@ -36,0 +33,0 @@ "ava": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3014
3
18
0
Updatedreact@^16.13.1