Skip to content

Provide reason react hook and component for manage page title (document.title)

License

Notifications You must be signed in to change notification settings

Qziem/reason-react-document-title

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reason React Document Title

Provide reason react hook and component for manage page title (document.title)

Installation

# 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"]
}

Usage

You can use one of three implementations: hook, component in Jsx3, component in Jsx2. Hook usage is recomended.

Hook

For example:

[@react.component]
let make = () => {
  DocumentTitle.useTitle("My title");

  <div>
    ... some stuff
  </div>
};

Component (Jsx3)

[@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>,
};

Component (Jsx2)

Library also provide component for older Jsx2 version. If you must, use it like this:

<DocumentTitleJsx2 title="My title" />

It also supports children.

How it works?

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 :)

About

Provide reason react hook and component for manage page title (document.title)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages