A React component for nested document title management, allowing parent and child components to collaboratively build the document title. Version 1.0.1 is the latest stable release; no active development or major updates have occurred since its initial release. It supports both CommonJS and ES6 modules, works with React Router for route-driven titles, and provides server-side rendering support via a flushTitle() function. Unlike simpler solutions, it handles dynamic title composition from deeply nested components without requiring manual string concatenation or context propagation.
npm install react-title-componentNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates nested Title components composing the document title dynamically, and server-side flushing.
Ensure every component that renders a Title always renders it (unconditionally). Use state or other means to control content without adding/removing the Title component.
Add prop-types as a dependency (npm install prop-types) if using React 16+.
Access via window.ReactTitle.default or use a bundler with ES modules.
Call flushTitle() immediately after renderToString (or renderToNodeStream) before any further rendering.
Always provide a string template or a function that returns a string.
Use class components extending React.Component or functional components with hooks.
Remount the component with new props to update the title, or use a different approach for dynamic titles.
Change to default import: import Title from 'react-title-component'
Use: var Title = require('react-title-component').default;Add a string or function render prop to the Title component.
Ensure you import { flushTitle } from 'react-title-component' and call it after rendering.