File tree Expand file tree Collapse file tree 7 files changed +58
-6
lines changed
Expand file tree Collapse file tree 7 files changed +58
-6
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ export default [
3030 ...reactHooks . configs . recommended . rules ,
3131 "react/prop-types" : "off" ,
3232 "react/jsx-no-target-blank" : "off" ,
33+ "react/rule-of-hook" : "off" ,
34+ "react-hooks/rules-of-hooks" : "off" ,
3335 "react-refresh/only-export-components" : [
3436 "warn" ,
3537 { allowConstantExport : true } ,
Original file line number Diff line number Diff line change 11import Button from "./components/Button" ;
2+ import Counter from "./components/Counter" ;
23import Input from "./components/Input" ;
34import Wrapper from "./components/Wrapper" ;
45
@@ -7,6 +8,8 @@ function App() {
78 < Wrapper >
89 < Input />
910 < Button />
11+ < h3 > 카운터</ h3 >
12+ < Counter />
1013 </ Wrapper >
1114 ) ;
1215}
Original file line number Diff line number Diff line change 11import { StyledButton } from "./styles" ;
22
33function Button ( ) {
4- return < StyledButton onClick = { alert ( "제출 버튼 클릭" ) } > 제출</ StyledButton > ;
4+ return < StyledButton onClick = { ( ) => alert ( "제출 버튼 클릭" ) } > 제출</ StyledButton > ;
55}
66
77export default Button ;
Original file line number Diff line number Diff line change 1+ import { useState } from "react" ;
2+ import { StyledButton , ConterWrapper } from "./styles" ;
3+
4+ function Counter ( ) {
5+ const [ isSent , setIsSent ] = useState ( false ) ;
6+
7+ if ( isSent ) {
8+ return < div > 전송되었습니다.</ div > ;
9+ } else {
10+ const [ count , setCount ] = useState ( 0 ) ;
11+ return (
12+ < ConterWrapper >
13+ { count }
14+ < ButtonWrapper >
15+ < StyledButton onClick = { ( ) => setCount ( count + 1 ) } >
16+ 더하기
17+ </ StyledButton >
18+ < StyledButton onClick = { ( ) => setIsSent ( true ) } > Send</ StyledButton >
19+ </ ButtonWrapper >
20+ </ ConterWrapper >
21+ ) ;
22+ }
23+ }
24+
25+ export default Counter ;
Original file line number Diff line number Diff line change 11import { StyledInput } from "./styles" ;
22
33function Input ( ) {
4- return < StyledInput /> ;
4+ return (
5+ < >
6+ < h3 > 입력</ h3 >
7+ < StyledInput />
8+ </ >
9+ ) ;
510}
611
712export default Input ;
Original file line number Diff line number Diff line change 11import { StyledWrapper } from "./styles" ;
2- function Wrapper ( ) {
2+ function Wrapper ( { children } ) {
33 const clickFunc = ( ) => {
44 alert ( "배경 클릭" ) ;
55 } ;
66 return (
7- < StyledWrapper onClick = { clickFunc ( ) } > 배경을 클릭할 수 있어요</ StyledWrapper >
7+ < StyledWrapper onClick = { clickFunc ( ) } >
8+ < h2 > 배경을 클릭할 수 있어요</ h2 >
9+ { children }
10+ </ StyledWrapper >
811 ) ;
912}
1013
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import styled from "styled-components";
22
33export const StyledWrapper = styled . form `
44 width: 100%;
5- height: 300px;
65 background-color: skyblue;
76 display: flex;
87 align-items: center;
@@ -18,7 +17,6 @@ export const StyledInput = styled.input`
1817 border: none;
1918 border-radius: 15px;
2019 font-size: 20px;
21- margin-top: 20px;
2220 z-index: 10;
2321 &:focus {
2422 outline: none;
@@ -35,3 +33,19 @@ export const StyledButton = styled.button`
3533 font-size: 20px;
3634 margin-top: 20px;
3735` ;
36+
37+ export const ConterWrapper = styled . div `
38+ width: 100%;
39+ display: flex;
40+ justify-content: center;
41+ align-items: center;
42+ flex-direction: column;
43+ ` ;
44+
45+ export const ButtonWrapper = styled . div `
46+ display: flex;
47+ justify-content: center;
48+ align-items: center;
49+ flex-direction: row;
50+ gap: 10px;
51+ ` ;
You can’t perform that action at this time.
0 commit comments