-
Notifications
You must be signed in to change notification settings - Fork 0
/
Complex.jsx
66 lines (51 loc) · 1.66 KB
/
Complex.jsx
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
import React from 'react'
function Complex() {
return (
<div>
<div><h1>Complicated JSX</h1>
<div>
<p>paragraph1</p>
<p>paragraph2</p>
<p>paragraph3</p>
<div>
<ul>
<li>css</li>
<li>html</li>
<li>js</li>
</ul>
</div>
</div>
</div>
</div>
)
}
export default Complex
/* The last challenge was a simple example of JSX, but JSX can represent more complex HTML as well.
One important thing to know about nested JSX is that it must return a single element.
This one parent element would wrap all of the other levels of nested elements.
For instance, several JSX elements written as siblings with no parent wrapper element will not transpile.
Here's an example:
Valid JSX:
<div>
<p>Paragraph One</p>
<p>Paragraph Two</p>
<p>Paragraph Three</p>
</div>
Invalid JSX:
<p>Paragraph One</p>
<p>Paragraph Two</p>
<p>Paragraph Three</p>
Define a new constant JSX that renders a div which contains the following elements in order:
An h1, a p, and an unordered list that contains three li items. You can include any text you want within each element.
Note: When rendering multiple elements like this, you can wrap them all in parentheses, but it's not strictly required. Also notice this challenge uses a div tag to wrap all the child elements within a single parent element. If you remove the div, the JSX will no longer transpile. Keep this in mind, since it will also apply when you return JSX elements in React components.
*/
// SOLUTION HERE
const JSX = <div>
<h1>Heading.</h1>
<p>Paragraph</p>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</div>;