0

I'm using React Router to move from component to another on same page without refreshing, i want to change the page title based on the current active component.

Here's my code

<Router forceRefresh={false} >
    <div className="sidemenu">
            <ul>
              <li><Link to="/">Home/Today</Link></li>
              <li><Link to="/profile">My profile</Link></li>
              <li><Link to="/schedule">My Schedule</Link></li>
            </ul>
    </div>
{this.routes.map((route, index) => (
          // Render more <Route>s with the same paths as
          // above, but different components this time.

          <Route
            key={index}
            path={route.path}
            exact={route.exact}
            component={route.main}
          />
        ))}
</Router>

I tried things like document.title = "Page title" but i don't know how to render it in Route or on specific component

Zeyad Etman
  • 2,250
  • 5
  • 25
  • 42

0 Answers0