Created
May 20, 2020 19:17
-
-
Save AZagatti/edaa7e677dd46b6f29a573a81bbdc4a1 to your computer and use it in GitHub Desktop.
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
import React, { useState, useEffect, memo } from "react"; | |
import useCount from "../hooks/useCount"; | |
import "./styles.css"; | |
function Hooks() { | |
const [name, setName] = useState("Zagatti"); | |
const { count, increment, decrement } = useCount(); | |
useEffect(() => { | |
document.title = `${name}'s counter`; | |
}, [name]); | |
function updateName(e) { | |
setName(e.target.value); | |
} | |
return ( | |
<div id="section"> | |
<div class="top"> | |
<label>Nome:</label> | |
<input | |
type="text" | |
name="name" | |
placeholder="Seu nome" | |
value={name} | |
onChange={updateName} | |
/> | |
</div> | |
<div class="buttons"> | |
<button onClick={decrement}>-</button> | |
<span>{count}</span> | |
<button onClick={increment}>+</button> | |
</div> | |
</div> | |
); | |
} | |
export default memo(Hooks); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment