Setting Page Title with React-Router-Config

I would like to set the page titles via the config file that I’m using with react-router-config but I’m not sure the best approach. Props? Helmet?

routes.js

const routes = [
    {
        title: 'Home',
        path: '/',
        exact: true,
        component: PageOne,
        name: PageOne,
    },
    {
        title: 'PageOne',
        path: '/PageOne',
        exact: true,
        component: PageOne,
        name: PageOne,
    }
]

template.js

const Template = ({ route }) => {
    return (
        <>
            <Nav route={route} />
        </>
    )
}

nav.js

const Nav = () => {
    return (
        <div>
             <Link to="/">Home</Link>
             <Link to="/PageOne">Page One</Link>
        </div>
    )
}

index.js

ReactDOM.render(
        <BrowserRouter>{renderRoutes(routes)}</BrowserRouter>,
    document.getElementById('root')
)

35 thoughts on “Setting Page Title with React-Router-Config”

  1. I like how well-written and informative your content is. You have actually given us, your readers, brilliant information about Senior Health and not just filled up your blog with flowery texts like many blogs today do. If you visit my website xrank.cyou I’m sure you can also find something for yourself.

    Reply

Leave a Comment