Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page title management in the navbar #20

Open
tperale opened this issue Dec 24, 2020 · 2 comments
Open

Page title management in the navbar #20

tperale opened this issue Dec 24, 2020 · 2 comments

Comments

@tperale
Copy link
Collaborator

tperale commented Dec 24, 2020

So far there is no way to modify the title of the page according to the active page. A library like react-helmet should do the trick,

@tperale
Copy link
Collaborator Author

tperale commented Dec 25, 2020

In commit 3836ff2 I set the title with a simple switch case. A more declarative way of using a component in the actual would be more "react-way".

I use a simple switch case in the Navbar.js that check the current url.

const getName = (link) => {
  switch (link) {
    case "/parts":
      return "Parts printing page";
    case "/inventory":
      return "Inventory recap page";
    case "/printer":
      return "Printer fleet overview";
    case "/":
      return "Home page";
    default:
      return link;
  }
};

@tperale
Copy link
Collaborator Author

tperale commented Jan 3, 2021

This example creates a declarative way that handles the state change of component. This example is used to change the document.title but could be readapted to set the title of the page.
https://github.com/gaearon/react-document-title/blob/master/index.js this library is using https://github.com/gaearon/react-side-effect/blob/master/src/index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant