hyeyeon-sun

customer component structured

...@@ -2,22 +2,44 @@ import React, { Component } from 'react'; ...@@ -2,22 +2,44 @@ import React, { Component } from 'react';
2 import './App.css'; 2 import './App.css';
3 import Customer from './components/Customer' 3 import Customer from './components/Customer'
4 4
5 -const customer ={ 5 +const customers =[
6 + {
7 + 'id': 1,
8 + 'image': 'https://placeimg.com/64/64/any',
6 'name': '이혜연', 9 'name': '이혜연',
7 'birthday': '000416', 10 'birthday': '000416',
8 'gender': '여자', 11 'gender': '여자',
9 'job': '대학생' 12 'job': '대학생'
10 -} 13 +},
14 +{
15 + 'id': 2,
16 + 'image': 'https://placeimg.com/64/64/2',
17 + 'name': '김다은',
18 + 'birthday': '000101',
19 + 'gender': '여자',
20 + 'job': '재수생'
21 +},
22 +{
23 + 'id': 3,
24 + 'image': 'https://placeimg.com/64/64/3',
25 + 'name': '김석희',
26 + 'birthday': '900103',
27 + 'gender': '남자',
28 + 'job': '회사원'
29 +},
30 +
31 +]
11 32
12 class App extends Component { 33 class App extends Component {
13 render() { 34 render() {
14 return ( 35 return (
15 - <Customer 36 + <div>
16 - name={customer.name} 37 + {
17 - birthday={customer.birthday} 38 + customers.map(c=> { return (<Customer key={c.id} id={c.id} image={c.image} name={c.name} birthday={c.birthday} gender={c.gender} job={c.job} />
18 - gender={customer.gender} 39 + )
19 - job={customer.job} 40 + })
20 - /> 41 + }
42 + </div>
21 ); 43 );
22 } 44 }
23 } 45 }
......
...@@ -3,14 +3,36 @@ import React from 'react'; ...@@ -3,14 +3,36 @@ import React from 'react';
3 class Customer extends React.Component { 3 class Customer extends React.Component {
4 render(){ 4 render(){
5 return( 5 return(
6 + <div>
7 + <CustomerProfile id ={this.props.id} image = {this.props.image} name = {this.props.name}/>
8 + <CustomerInfo birthday = {this.props.birthday} gender = {this.props.gender} job = {this.props.job}/>
9 + </div>
10 + );
11 + }
12 +}
13 +
14 +class CustomerProfile extends React.Component{
15 + render(){
16 + return(
6 <div> 17 <div>
7 - <h2>{this.props.name}</h2> 18 + <img src={this.props.image}alt="profile"/>
8 - <p>{this.props.birthday}</p> 19 + <h2>{this.props.name}({this.props.id})</h2>
9 - <p>{this.props.gender}</p>
10 - <p>{this.props.job}</p>
11 </div> 20 </div>
12 ); 21 );
13 } 22 }
23 +}
24 +
25 +class CustomerInfo extends React.Component {
26 + render() {
27 + return (
28 + <div>
29 + <p>{this.props.birthday}</p>
30 + <p>{this.props.gender}</p>
31 + <p>{this.props.job}</p>
32 + </div>
33 + )
34 + }
35 +
14 36
15 } 37 }
16 38
......