Last active
April 12, 2021 14:32
-
-
Save stoneboyindc/402a5e14a9f190780254368131735fc5 to your computer and use it in GitHub Desktop.
SetFontSize button
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
// App | |
import React, { useState } from "react"; | |
import Content from "./Content"; | |
import Header from "./Header"; | |
function App () { | |
const [loggedIn, setLoggedIn] = useState(false); | |
const toggleLoggedIn = () => setLoggedIn(!loggedIn); | |
const [fontSize, setFontSize] = useState(12); | |
const increaseSize = () => setFontSize(fontSize+2); | |
return ( | |
<div> | |
<Header loggedIn={loggedIn} handleLoggedInClick={toggleLoggedIn} handleSizeClick={increaseSize} /> | |
<Content loggedIn={loggedIn} fontSize={fontSize} /> | |
</div> | |
); | |
} | |
export default App; | |
// Header | |
import React from "react"; | |
function Header (props) { | |
const { loggedIn, handleLoggedInClick, handleSizeClick } = props; | |
return ( | |
<div> | |
<button onClick={handleLoggedInClick}> | |
{loggedIn ? "Log Out" : "Log In"} | |
</button> | |
<button onClick={handleSizeClick}> | |
increase size | |
</button> | |
</div> | |
); | |
} | |
export default Header; | |
// Content | |
import React from "react"; | |
function Content (props) { | |
const { loggedIn, fontSize } = props; | |
return loggedIn && <p style={{ fontSize: fontSize }}>CONTENT</p>; | |
} | |
export default Content; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment