Click here to Skip to main content
15,879,038 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to put the 'home' function into 'Header', however I have no clue how to without breaking it. I am trying to welcome a user who logs in via Google their name and profile pic with a message...

I am trying to get rid of the Home function, but I am still trying to authenticate it.

(learning how to code, sorry for any silly mistakes)

Thanks!

What I have tried:

Putting the home inside Header
Posted
Updated 14-Jul-22 3:03am
v5

1 solution

Remove your Home constant completely, use the div inside your header as you are already making a call to "user" there, something like this (you need to play with it as I have no idea what end result you require) -

function Header() {
  const [user, setUser] = useState(null);

  useEffect(() => {
    firebase.auth().onAuthStateChanged((user) => {
      setUser(user);
    });
  }, []);
  return (
//ADD code her...
<div>
    <h1>
      Hello, <span></span>
      {user.displayName}
    </h1>
    
     auth.signOut()}>
      Sign out
    
  </div>
    <menu secondary="">
      <menu.menu position="right">
        <div>{user ? <home user="{user}"> : <login>}</div>
      
    
  );
}

export default Header;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900