-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
link logic for navbar, prop clean up in login, logout function in app
- Loading branch information
Showing
4 changed files
with
39 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
import React from "react" | ||
import { Link } from 'react-router-dom' | ||
import React, { useContext } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { UserContext } from "./App"; | ||
|
||
function NavBar() { | ||
const { currentUser, handleLogOut } = useContext(UserContext); | ||
return ( | ||
<nav id="navigation" > | ||
<Link to="/">Home</Link> | ||
<Link to="/randomrecipe">Random Recipe</Link> | ||
<Link to="/recipebook">Your Recipe Book</Link> | ||
<Link to="/recipeform">Add Recipe</Link> | ||
<Link to="/login">Log In</Link> | ||
<Link to="/signup">Sign Up</Link> | ||
<nav id='navigation'> | ||
<Link to='/'>Home</Link> | ||
{currentUser.id ? ( | ||
<> | ||
<Link to='/randomrecipe'>Random Recipe</Link> | ||
<Link to='/recipebook'>Your Recipe Book</Link> | ||
<Link to='/recipeform'>Add Recipe</Link> | ||
<button onClick={handleLogOut}>Log out</button> | ||
</> | ||
) : ( | ||
<> | ||
<Link to='/login'>Log In</Link> | ||
<Link to='/signup'>Sign Up</Link> | ||
</> | ||
)} | ||
</nav> | ||
) | ||
); | ||
} | ||
|
||
export default NavBar | ||
export default NavBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters