diff --git a/src/Counter/index.js b/src/Counter/index.js index c6686e6..35baf31 100644 --- a/src/Counter/index.js +++ b/src/Counter/index.js @@ -1,13 +1,25 @@ import React from "react"; import "./index.css"; -// Counter의 시작은 0부터 시작합니다. const Counter = () => { + const [count, setCount] = React.useState(0); + + const handleMinus = () => { + if (count > -10) { + setCount(count - 1); + } + }; + + const handlePlus = () => { + if (count < 10) { + setCount(count + 1); + } + }; return (
- -

{/** 여기에 카운트가 나타납니다. 주석 삭제 후 작성해주세요 */}

- + +

{count}

+
); }; diff --git a/src/Input/index.js b/src/Input/index.js index 5802db4..4487de1 100644 --- a/src/Input/index.js +++ b/src/Input/index.js @@ -1,7 +1,7 @@ import React from "react"; -const Input = () => { - return ; +const Input = ({ onChange }) => { + return ; }; export default Input; diff --git a/src/ShowBox/index.js b/src/ShowBox/index.js index 65d55d1..1374af9 100644 --- a/src/ShowBox/index.js +++ b/src/ShowBox/index.js @@ -1,13 +1,19 @@ -import React from "react"; +import React, { useState } from "react"; import "./index.css"; import Input from "../Input"; const ShowBox = () => { + const [text, setText] = useState(""); + + const handleChange = (e) => { + setText(e.target.value); + }; + return (
- -

- {/* 여기 안에 Input에서 입력한 값이 나와야 해요. 주석은 지워주세요 */} + +

+ {text || "값을 입력해주세요"}

);