Provide reason react hook and component for manage page title (document.title)
# yarn
yarn add reason-react-document-title
# npm
npm install reason-react-document-title --save
Remeber, add to bsconfig.json
:
{
"bs-dependencies": ["reason-react-document-title"]
}
You can use one of three implementations: hook, component in Jsx3, component in Jsx2. Hook usage is recomended.
For example:
[@react.component]
let make = () => {
DocumentTitle.useTitle("My title");
<div>
... some stuff
</div>
};
[@react.component]
let make = () => {
<div>
<DocumentTitle title="My title" />
... some stuff
</div>
};
Or if you like:
[@react.component]
let make = () => {
<DocumentTitle title="My title">
<div>
... some stuff
</div>
</DocumentTitle>,
};
Library also provide component for older Jsx2 version. If you must, use it like this:
<DocumentTitleJsx2 title="My title" />
It also supports children.
Changing title parameter will affect on page title (document.title) automatically. When component is unmounted, document.title value will be set to empty string.
If find any problems or have improvement idea, feel free to create issue :)