Skip to content
This repository was archived by the owner on Sep 19, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
# react-profile
<h2> props와 state의 차이점 </h2>

## 실행 방법
props 는 부모 컴포넌트가 자식 컴포넌트에게 주는 값.
자식 컴포넌트에서는 props 를 받아오기만하고, 받아온 props 를 직접 수정은 불가.
반면에 state 는 컴포넌트 내부에서 선언하며 내부에서 값을 변경 가능.

```
npm install
npm run start
```

- npm install : 필요한 모든 패키지를 설치합니다. 처음 1번만 실행하면 됩니다.
- npm run start : react 어플리케이션을 브라우저에서 실행합니다.

## 미션 설명

[미션 설명](./docs/mission-description/README.md)

## 미션 제출 방법

[미션 제출 방법](./docs/how-to-submit/README.md)
47 changes: 45 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
import React, {Component} from 'react';
import Introduction from './Introduction';

class App extends Component {
constructor(props){
super(props);
this.state = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ key: value } 형식으로 만든 객체를 JSON(JavaScript Object Notation) 이라고 해요.
JSON 위키 백과 링크인데 학습에 참고하시면 좋을 것 같아요.

근데 이 안에 데이터가 많아지기 시작하면 한 줄에 쓰는 것 보다 줄을 나눠서 쓰는 게 더 보기 좋아요.
자바스크립트 스타일 가이드 인데 여기 중간에 보시면 Object Rules 라는 소제목 부분을 보면 짧은 객체들은 한 줄로 압축해서 표현해도 되지만 길어지면 줄을 나눠서 표기하는 것을 추천(?)하고 있네요 😂

info:[
{
key:1,
id:1,
name:"최수민",
university:"서강",
major:"컴퓨터공학",
age:25,
emotion:"행복",
animal:["사자", "토끼", "뱀"]
},
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intellij WebStorm 을 쓴다면 이런 부분은 ctrl + alt + L (윈도우 맞죠?) 을 누르면 알아서 맞춰줄꺼예요 !

VS code 를 쓴다면 shift + alt + F 를 눌러보세요 !

이런 기능을 ide 의 auto formatting 이라고 합니다.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다^^77 일일이 하는 거 번거로웠는데 좋은 기능 가르쳐주셔서 감사합니다.

key:2,
id:2,
name:"이한길",
university:"홍익" ,
major:"법학",
age:29,
emotion:"불행",
animal:["펭귄"]
},
{
key:3,
id:3,
name:"김서영",
university:"이화여자",
major:"사이버보안학",
age:22,
emotion:"불행",
animal:["웜", "트로이목마"]
}
]
}
}

render() {
return <div className="App">Hello React!</div>;
return <div className="App">
<Introduction data={this.state.info[0]}></Introduction>
<Introduction data={this.state.info[1]}></Introduction>
<Introduction data={this.state.info[2]}></Introduction>
</div>;
}
}

}
export default App;
30 changes: 30 additions & 0 deletions src/Introduction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, {Component} from 'react';

class Introduction extends Component {
render() {
var data = this.props.data;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시간이 되신다면 var, const, let 에 대하여 학습해보시는 것은 어떨까요?

이 글의 제목에 있는 ES가 슬랙 qna 방에 올린 글에서 설명한 ECMA Script (표준화된 자바스크립트) 예요 ㅎㅎ

링크 참고해주세요 !

var animalData = this.props.data.animal;
var animalList = [];
var index=0;

while(index<animalData.length){
animalList.push(<li>{animalData[index]}</li>);
index++;
}

return <div className="Introduction">
<h1> {data.name} </h1>
<article>
<p>안녕하세요 저는 {data.university}대학교의 {data.major}과에 다니고 있습니다.</p>
<p>올해는 {data.age}살인데 내년엔 {data.age+1}이에요.</p>
<p>지금 기분은 {data.emotion}해요!</p>
</article>
<h2>좋아하는 동물</h2>
<ul>
{animalList}
</ul>
</div>;
}
}

export default Introduction;