feat/components/header: added header with testUser and onClick functi…#21
feat/components/header: added header with testUser and onClick functi…#21Pawel-dev5 wants to merge 2 commits intomasterfrom
Conversation
…on to change logIn/logOut status
| function changeLogin() { | ||
| if (users.isLogged === false) { | ||
| setUsers((prevState) => ({ | ||
| ...prevState, | ||
| isLogged: true, | ||
| })); | ||
| } else { | ||
| setUsers((prevState) => ({ | ||
| ...prevState, | ||
| isLogged: false, | ||
| })); | ||
| } | ||
| } |
There was a problem hiding this comment.
Nice destructuring! Here's shorter version though 😄
| function changeLogin() { | |
| if (users.isLogged === false) { | |
| setUsers((prevState) => ({ | |
| ...prevState, | |
| isLogged: true, | |
| })); | |
| } else { | |
| setUsers((prevState) => ({ | |
| ...prevState, | |
| isLogged: false, | |
| })); | |
| } | |
| } | |
| const toggleIsUserLogged = () => { | |
| setUsers((prevState) => ({ | |
| ...prevState, | |
| isLogged: !prevState.isLogged, | |
| })); | |
| } |
There was a problem hiding this comment.
Dzięki, zmieniłem zgodnie z sugestią :)
| }; | ||
|
|
||
| export default function Header() { | ||
| const [users, setUsers] = useState(testUser); |
There was a problem hiding this comment.
users (plural) implies that there's multiple users. Use just user, setUser
| <Typography.Nav> | ||
| <li>Explore</li> | ||
| {users.isLogged ? ( | ||
| <li> |
There was a problem hiding this comment.
Instead of using native html elements, create styled-component for that styled.li. That way you don't need to style li in Nav. Just style it independently
There was a problem hiding this comment.
utworzona lista
| return ( | ||
| <DefaultLayout gapRow={3} marginVertical={5} marginHorizontal="auto"> | ||
| <DefaultLayout gapRow={3} marginHorizontal="auto"> | ||
| <Header /> |
There was a problem hiding this comment.
Since header will always be present, I think importing it in src/index.tsx will be better. We want to display header everywhere not only in / (home route)
|
@Pawel-dev5 can you update the branch please. |
feat/components/header: added header with testUser and onClick function to change logIn/logOut status