Repository navigation
context pagetitle
The PageTitle Context provides a simple way to manage and update the current page title across your React application. It is useful for setting the document title or displaying the current page name in headers, breadcrumbs, or other UI elements.
Wrap your application (or a subtree) with the PageTitleProvider to enable access to the page title context:
import { PageTitleProvider } from 'src/context/pageTitle/PageTitleProvider';
<PageTitleProvider>
{/* your app components */}
</PageTitleProvider>Use the usePageTitle hook to access and update the page title from any component within the provider:
import { usePageTitle } from 'src/context/pageTitle/usePageTitle';
const { pageTitle, setPageTitle } = usePageTitle();
// Read the current title
console.log(pageTitle);
// Update the title
setPageTitle('Dashboard');Returns an object with:
-
pageTitle: string— The current page title. -
setPageTitle: (title: string) => void— Function to update the page title.
import { usePageTitle } from 'src/context/pageTitle/usePageTitle';
function Dashboard() {
const { setPageTitle } = usePageTitle();
React.useEffect(() => {
setPageTitle('Dashboard');
}, [setPageTitle]);
return <h1>Dashboard</h1>;
}- To display or update the current page title in your app's UI.
- To synchronize the document title with navigation.
- To provide a consistent way for nested components to update the page title.
See also:
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository