react-use#useTitle TypeScript Examples

The following examples show how to use react-use#useTitle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: header.tsx    From platyplus with MIT License 6 votes vote down vote up
HeaderTitleWrapper: React.FC<{
  title?: string
  component?: React.ReactNode
  previous?: boolean | string
}> = ({ title, component: Component, children, previous }) => {
  useTitle(title)
  const [container] = useTitleContainer()
  const navigate = useNavigate()
  const PreviousButton = previous ? (
    <IconButton
      appearance="subtle"
      onClick={() =>
        typeof previous === 'boolean' ? navigate(-1) : navigate(previous)
      }
      size="lg"
      icon={<Icon icon="page-previous" />}
    />
  ) : null
  return (
    <>
      <Portal container={() => container}>
        {PreviousButton}
        <span style={{ marginLeft: '10px' }}>{Component || title}</span>
      </Portal>
      {children}
    </>
  )
}