diff --git a/1week/class/src/App.js b/1week/class/src/App.js index 8fbe34102..e9530e117 100644 --- a/1week/class/src/App.js +++ b/1week/class/src/App.js @@ -4,68 +4,52 @@ import React, { Component } from "react"; import logo from "./logo.svg"; import "./App.css"; //css를 불러옴 파일 이름은 달라도 된다. -import Counter from "./Counter.js"; // 카운터를 표시해줄 컴포넌트 호출 +import Counter from "./Counter"; +import Clock from "./Clock"; +//1week homework //Component라는 react의 class를 상속 받음 class App extends Component { - //constructor는 컴포넌트가 마운트(생성)될때 데이터를 초기화 시켜 주고 싶을때 사용한다. - //react에서는 state를 contructor에서 선언 해주어야 한다. - constructor(props) { - super(props); - //상속을 받을때 this를 사용하기 위해서는 super를 선언해준다. - //super를 사용하면 부모 클래스의 constructor를 호출해서 데이터를 초기화 해준다. - - //number의 값을 state로 선언한다. - //state는 상태를 저장하는 변수로 현재 컴포넌트에서 데이터를 관리하거나 ui부분의 상태를 관리할때 사용 - this.state = { - number: 0 - }; - } - - //함수 실행시 number값이 1 증가 - handleIncrease = () => { - const { number } = this.state; - - //this.setState는 state의 값을 변경할때 사용 하는 함수 - //this.state.number 에 직접 데이터를 변경할 수 없다. + state = { + pnum: 0 + }; + handlePInc = () => { this.setState({ - number: number + 1 + pnum: this.state.pnum + 1 }); }; - - //함수 실행 시 number값이 1감소 - handleDecrease = () => { - this.setState(({ number }) => ({ - number: number - 1 - })); + handlePDnc = () => { + this.setState({ + pnum: this.state.pnum - 1 + }); + }; + handlePReset = () => { + this.setState({ + pnum: 0 + }); }; - //jsx를 화면에 보여줄때 render함수를 호출해서 return을 해야 한다. - //jsx는 js를 html처럼 사용할수 있게 해주는 언어?이다. render() { return ( - //jsx를 return 할때 두개 이상의 엘리먼트가 있으면 - //항상 감싸주어야 한다. 아래에서는 div로 엘리먼트를 감싸줌.
logo - {/* - 위에서 import 한 Counter 컴포넌트를 선언 props를 이용해서 - handleIncrease와 handleDecrease함수와 number의 값을 전달 한다. - props는 상위컴포넌트에서 하위컴포넌트로 데이터와 함수를 전달할때 사용 하는 속성으로 - props로 데이터를 받은 컴포넌트에서는 데이터 변경이 불가 하다. - */} +

Welcome to React

+
+

+ To get started, edit src/App.js and save to reload. +

); } } - //외부에서 import로 불러오기 위해서는 export를 해줘야 한다. //default는 하나의 모듈 혹은 class만 export할때 써준다. //https://enyobook.wordpress.com/2016/08/17/export-default%EC%97%90-%EB%8C%80%ED%95%B4/ diff --git a/1week/class/src/Clock.js b/1week/class/src/Clock.js new file mode 100644 index 000000000..03ab465a0 --- /dev/null +++ b/1week/class/src/Clock.js @@ -0,0 +1,41 @@ +import React, { Component } from "react"; + +class Clock extends Component { + state = { + date: new Date() + }; + + //CB 호출 순서를 파악하자. + handleIncrease() { + this.intervalId = setInterval(() => { + this.setState({ date: new Date() }); + }, 1000); + } + handleDecrease() { + this.intervalId = clearInterval(() => { + this.setState({ date: Date() }); + }); + } + + componentDidUpdate() { + console.log("update"); + } + + render() { + console.log("render"); + return ( +
+

Clock

+

{this.state.date.toLocaleTimeString()}

+

+ +

+

+ +

+
+ ); + } +} + +export default Clock; diff --git a/1week/class/src/Counter.js b/1week/class/src/Counter.js index ac968234a..eb5694f4b 100644 --- a/1week/class/src/Counter.js +++ b/1week/class/src/Counter.js @@ -1,17 +1,44 @@ import React, { Component } from "react"; -//react를 사용하기 위해서 react 라이브러리에서 React와 Component를 호출함 -//Counter 컴포넌트를 생성 하고 Component를 상속 class Counter extends Component { - //jsx를 화면에 그려주는 함수 + state = { + num: 0 + }; + + //this, binding + handleInc = () => { + this.setState({ + num: this.state.num + 2 + }); + }; + handleDnc = () => { + this.setState({ + num: this.state.num - 2 + }); + }; + handleReset = () => { + this.setState({ + num: 0 + }); + }; + render() { return ( - //두개 이상의 엘리먼트를 return 할때는 반드시 div로 감싸야 한다.

Counter

-
값: {this.props.number}
- - +

값 : {this.props.number}

+

+ + + +

+

Counter

+

값 : {this.state.num}

+

+ + + +

); } diff --git a/test b/test new file mode 100644 index 000000000..ffaf5b170 --- /dev/null +++ b/test @@ -0,0 +1,292 @@ +commit 84fdfee09cc151c1f83be714ff6b94e70783c84d (HEAD -> 1week, origin/1week) +Author: jihyun01 +Date: Sat Dec 21 14:27:41 2019 +0900 + + test + +commit a34ab055e5c8da804990fda88a3c5b12172bbd73 +Author: jeonjihun +Date: Sun Mar 31 00:29:00 2019 +0900 + + Remove homeworkcode + +commit df6427dcdbc916bac3b25854935f2e99cd372650 +Author: tiuln2010 +Date: Thu Mar 14 14:25:18 2019 +0900 + + change folder name and add homework folder + +commit c69e64826c11f6914ad05a5240f7527a9a60ac3a +Author: Eungjin +Date: Fri Jan 11 02:06:55 2019 +0900 + + . + +commit 52e9b16716e79790f0059a5ccc26787df6b597ec +Author: Eungjin +Date: Fri Jan 11 02:05:55 2019 +0900 + + . + +commit 1c25e7bf0a318a57aa7b8877705f55048a490d10 +Author: Eungjin +Date: Fri Jan 11 00:59:03 2019 +0900 + + 1week + +commit 1ddef67433ede062432b40310ebccab286503cbd +Author: jeonjihun +Date: Sat Jan 5 02:11:26 2019 +0900 + + add readme in week4 + +commit f2528429e5f313e8422d65f8f1a17ca3808eaba9 +Author: jeonjihun +Date: Sat Jan 5 02:10:02 2019 +0900 + + remove 5week & 6week + +commit 32ae89d4515ad11be7023b7b824a0ac5b034291c +Author: jeonjihun +Date: Sat Jan 5 02:07:01 2019 +0900 + + modify code + +commit 322fdcd1fbfab2b6bf9e4b2ed977c4e32abf8cd6 +Author: Eungjin +Date: Sun Dec 30 00:52:21 2018 +0900 + + addited code after saturdatclass + +commit bc6f4bc70e265169c33d3f61ab2077eeddca0c02 +Author: Eungjin +Date: Sat Dec 29 09:34:27 2018 +0900 + + . + +commit 9eab8b692713d1325b993b6d0948b0a899f17ffb +Author: Eungjin +Date: Sat Dec 29 09:31:44 2018 +0900 + + test commit + +commit 98605f0f5473332266a33382311f4847a65ccd5b +Author: Eungjin +Date: Sat Dec 29 09:29:00 2018 +0900 + + add week2 keep2, week3 keep 2,3 folder to gitignore: + +commit f87351b36ea757269a2e5707533fd5ebc3cc0db0 +Author: Eungjin +Date: Sat Dec 29 02:20:56 2018 +0900 + + week3 material complete + +commit cdd629d031808adf1b044d26f7d7d73e546dd58c +Author: Eungjin +Date: Fri Dec 28 23:21:54 2018 +0900 + + fix submit errors + +commit 784dc4f47dcaf4d0408bc3c5e93e7b43d57f2b34 +Author: Eungjin +Date: Fri Dec 28 15:56:40 2018 +0900 + + week3 material 3. proptypes example in Note + +commit cf297835d2a81fac0b39bfe4987d2028c1e55876 +Author: Eungjin +Date: Fri Dec 28 11:31:15 2018 +0900 + + material 2.Coditional Rendering done + +commit c8ac2ab82ad1430fc3e7ba94ed586de6f2015c07 +Author: Eungjin +Date: Fri Dec 28 10:39:26 2018 +0900 + + week3 homework done + +commit 1eb66b5e770714fc9efedf21fd105a0c9c4698fe +Author: Eungjin +Date: Fri Dec 28 09:55:03 2018 +0900 + + . + +commit 77287ae6c6ed2de431298594280952e875d2fce8 +Merge: 661aa91 1ea347a +Author: Eungjin +Date: Wed Dec 26 23:20:22 2018 +0900 + + Merge branch 'master' of https://github.com/yesjin-git/ReactStudy + +commit 661aa914b578e7e696cd5991fc632eaa8a503859 +Author: Eungjin +Date: Wed Dec 26 23:19:54 2018 +0900 + + . + +commit 957f96ca56452f495059278c55142031b5745df3 +Author: Eungjin +Date: Wed Nov 14 17:07:04 2018 +0900 + + classifying contents + +commit 1ea347a02b8cc4fdbb1842440af38df11c555e67 +Author: jeonjihun +Date: Mon Nov 12 17:42:15 2018 +0900 + + add explanation to app.js + +commit 6767259bd6ecd8e2725b22cd45fb29010361277a +Author: Eungjin +Date: Mon Nov 12 15:41:03 2018 +0900 + + del width and margin style + +commit d22970886ee018f84def2933b45863c7259b998e +Merge: 8e6c01e 57a888a +Author: Eungjin +Date: Sat Nov 10 00:04:05 2018 +0900 + + Merge branch 'master' of https://github.com/yesjin-git/ReactStudy + +commit 8e6c01e6a5dcb386abe2bdeda25e3052cf648e9e +Author: Eungjin +Date: Sat Nov 10 00:03:49 2018 +0900 + + . + +commit e355e699a578e35c603e3d12e9a23a174c2bf9eb +Author: Eungjin +Date: Fri Nov 9 23:52:50 2018 +0900 + + completed week3 + +commit a96ca0f87568774687a8bc6b42506ba181235efa +Author: Eungjin +Date: Thu Nov 8 16:35:02 2018 +0900 + + simplifying 2week + +commit 57a888a42d7a45b286d697b9778525150dd2425e +Author: jeonjihun +Date: Thu Nov 8 16:25:23 2018 +0900 + + add counter example + +commit 4c65d2254be9ebe2f828515c8f22c7f2872db629 +Author: Eungjin +Date: Thu Nov 8 15:39:55 2018 +0900 + + renamed files + +commit b2b76a5aa84c796085d538034056088d6b05ec48 +Author: Eungjin +Date: Thu Nov 8 15:28:52 2018 +0900 + + added week3 projects + +commit 5b7b684def18a329432badcd1b33ef6e04742f4a +Author: jeonjihun +Date: Thu Nov 8 15:19:40 2018 +0900 + + add 1week example + +commit 42b911985cf4c6ebacda72b56358975b222faece +Author: Eungjin +Date: Thu Nov 8 15:14:00 2018 +0900 + + modified folder names + +commit 43cd76237695f52df72c71ff85ab2f79b3a8a50b +Merge: 239ed1c c105fab +Author: jeonjihun +Date: Thu Nov 8 15:09:50 2018 +0900 + + . + +commit c105fababa2ffed5ce4a297a506e8d1b99f5cbfc +Author: Eungjin +Date: Thu Nov 8 15:08:21 2018 +0900 + + modify code easily + +commit 239ed1ce0425e94f59ce20dd689866518b37fc6f +Merge: 16d812b 64bcdaf +Author: jeonjihun +Date: Thu Nov 8 15:07:25 2018 +0900 + + Merge branch 'master' of github.com:yesjin-git/ReactStudy + +commit 16d812b9294818920239811c352667e98559a0bc +Author: jeonjihun +Date: Thu Nov 8 15:07:12 2018 +0900 + + add api + +commit 64bcdaf42da19908e19c4acf00b2ab38f7cd0ed4 +Author: Eungjin +Date: Thu Nov 8 01:24:31 2018 +0900 + + added Keep + +commit 3180da89e957087079f7f6fadea4dad695291311 +Author: Eungjin +Date: Wed Nov 7 15:28:18 2018 +0900 + + added week1 + +commit 7139993d38b5b1da81fc7567a4dac9c4f890e38b +Author: jeonjihun +Date: Tue Nov 6 17:38:46 2018 +0900 + + add fullcontent state init + +commit 3f7a315e2e45460bcbfcaf6dfec0b360f3d44993 +Merge: a3ae547 776c88c +Author: jeonjihun +Date: Tue Nov 6 17:13:11 2018 +0900 + + modify conflict + +commit a3ae547682d29948473d98e533b32970f431811a +Author: jeonjihun +Date: Tue Nov 6 17:07:24 2018 +0900 + + modify 3week && add 4week + +commit 776c88c782b3f457c788913f40020437f2843ee0 +Author: jeonjihun +Date: Fri Nov 2 14:05:22 2018 +0900 + + add example + +commit e8e45f8d2a87910136ab2a84317fad797c73cc2c +Author: Yesjin +Date: Mon Oct 22 17:07:30 2018 +0900 + + Week1 Homework 2.2 Make Navbar, Main, Playlist components + +commit 845f5cb910910fd8e4bb2217bbc17a2424b3b779 +Author: Yesjin +Date: Mon Oct 22 17:00:56 2018 +0900 + + Week2 Homework 2.1 Make Navbar + +commit 86f3fa11923d51fc331a624f60abcba9dd58cee8 +Author: Yesjin +Date: Mon Oct 22 16:58:42 2018 +0900 + + Week1 Homework 1.2 Import Bootstrap + +commit 50291c173d58fa4583b31eb373cf95d832af9b35 +Author: Yesjin +Date: Mon Oct 22 16:56:59 2018 +0900 + + Week1 Homework 1.1 Install Bootstrap + +commit bd3d15f6f4dafa61f825497c1477063593ed0384 +Author: Yesjin +Date: Mon Oct 22 14:45:56 2018 +0900 + + Initial commit from Create React App