Skip to content

Latest commit

 

History

History
57 lines (45 loc) · 1.11 KB

index.en-US.md

File metadata and controls

57 lines (45 loc) · 1.11 KB

usePageTitle

A hook that change the document's title.

Examples

Default usage

import React from 'react';
import { usePageTitle } from '@vergiss/chooks';

function PageTitle() {
  usePageTitle('Hello World');

  return (
    <span>
      This page's title is Hello World
    </span>
  )
}

Advanced usage

import React from 'react';
import { usePageTitle } from '@vergiss/chooks';

function PageTitle() {
  // note that the `preservePreTitle` option set to false will
  // cause the hook never store the page's title before.
  usePageTitle('Hello World', { preservePreTitle: false });

  return (
    <span>
      This page's title is Hello World
    </span>
  )
}

API

usePageTitle(
  title: string,
  options?: {
    preservePreTitle: boolean
  }
)

Params

Property Description Type Default
title Necessary string -
options.preservePreTitle Optional boolean true