Lifecycle & Effects
useDocumentTitle
About
Sets the document title and optionally resets the title on unmount
Examples
Basic example
import { useDocumentTitle } from "rooks";
function App() {
useDocumentTitle("New document title");
return (
<div>
<h1>Document title is now "New document title"</h1>
</div>
);
}
export default App;
## Examples
### Basic example
```jsx
import { useDocumentTitle } from "rooks";
function App() {
useDocumentTitle("New document title");
return (
<div>
<h1>Document title is now "New document title"</h1>
</div>
);
}
export default App;Example with reset
import { useDocumentTitle } from "rooks";
function App() {
useDocumentTitle("New document title", { resetOnUnmount: true });
return (
<div>
<h1>
Document title is now "New document title" and will be reset on unmount
</h1>
</div>
);
}
export default App;Arguments
| Argument | Type | Description |
|---|---|---|
| title | string | The new document title |
| options | object | Options object |
| options.resetOnUnmount | boolean | Whether to reset the document title on unmount |
Return
void