I am currently developing in a react project and I want to show the current page title in my header. To currently do this, I am using the props.location.pathname and a switch-case to get the desired output.
This looks something like below.
var currentPathname = this.props.location.pathname;
switch (currentPathname) {
case '/':
return 'Home';
}
The amount of paths are adding up and I do not want to make one big switch-case. So I was wondering, if there is any better way to set a (custom) title depending on a path. I expected something to be available in the react-router but I have not found such a thing yet.
Any insights are welcome.