-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainConcepts.js
147 lines (125 loc) · 2.64 KB
/
MainConcepts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// crear un componente con composición
// componer múltiples componentes React juntos
// en el rendermétodo podrías escribir
return (
<App>
<Navbar />
<Dashboard />
<Footer />
</App>
)
// Example
const ChildComponent = () => {
return (
<div>
<p>I am the child</p>
</div>
);
};
class ParentComponent extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h1>I am the parent</h1>
{ /* change code below this line */ }
<ChildComponent />
{ /* change code above this line */ }
</div>
);
}
};
// usar React para representar componentes anidados
// Example
const TypesOfFruit = () => {
return (
<div>
<h2>Fruits:</h2>
<ul>
<li>Apples</li>
<li>Blueberries</li>
<li>Strawberries</li>
<li>Bananas</li>
</ul>
</div>
);
};
const Fruits = () => {
return (
<div>
{ /* change code below this line */ }
{ /* change code above this line */ }
</div>
);
};
class TypesOfFood extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h1>Types of Food:</h1>
{ /* change code below this line */ }
<Fruits />
<TypesOfFruit />
{ /* change code above this line */ }
</div>
);
}
};
// Compose React Components
class Fruits extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h2>Fruits:</h2>
{ /* change code below this line */ }
<NonCitrus />
<Citrus />
{ /* change code above this line */ }
</div>
);
}
};
class TypesOfFood extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h1>Types of Food:</h1>
{ /* change code below this line */ }
<Fruits />
{ /* change code above this line */ }
<Vegetables />
</div>
);
}
};
// renderizar un componente de clase al DOM
class TypesOfFood extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h1>Types of Food:</h1>
{/* change code below this line */}
<Fruits />
<Vegetables />
{/* change code above this line */}
</div>
);
}
};
// change code below this line
ReactDOM.render(<TypesOfFood />,
document.getElementById('challenge-node'));