Skip to content
Snippets Groups Projects
Commit f6387d49 authored by Martin Wighus Holtmon's avatar Martin Wighus Holtmon
Browse files

projectPart2/Problem1: Made updateHeader a bit safer

parent b99cbbb2
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ class TopBar extends React.Component { ...@@ -27,6 +27,7 @@ class TopBar extends React.Component {
updateHeader = (pathname) => { updateHeader = (pathname) => {
const path = pathname.split('/'); const path = pathname.split('/');
if (path[2] && path[3]) {
const user = PROG2053Models.userModel(path[3]); const user = PROG2053Models.userModel(path[3]);
let newContext = ''; let newContext = '';
if (path[2] === 'photos') { if (path[2] === 'photos') {
...@@ -34,6 +35,7 @@ class TopBar extends React.Component { ...@@ -34,6 +35,7 @@ class TopBar extends React.Component {
} }
newContext += `${user.first_name} ${user.last_name}`; newContext += `${user.first_name} ${user.last_name}`;
this.setState({headerContext: newContext}); this.setState({headerContext: newContext});
}
}; };
render() { render() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment