useTitle()
The useTitle()
hook allows the dynamic update of the document's title from your React components! The title passed to this hook can be attached to a piece of state, updating the state will therefore also update the title.
Import
import { useTitle } from 'react-haiku';
Usage
import { useState } from 'react';
import { useTitle } from 'react-haiku';
export const Component = () => {
const [title, setTitle] = useState('');
useTitle(title);
return <button onClick={() => setTitle('It works!')}>Update Title</button>
}