-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Expand file tree
/
Copy pathApp.js
More file actions
80 lines (76 loc) · 2.14 KB
/
App.js
File metadata and controls
80 lines (76 loc) · 2.14 KB
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
import { useState } from "react";
import "./styles.css";
const content = [
[
"React is extremely popular",
"It makes building complex, interactive UIs a breeze",
"It's powerful & flexible",
"It has a very active and versatile ecosystem"
],
[
"Components, JSX & Props",
"State",
"Hooks (e.g., useEffect())",
"Dynamic rendering"
],
[
"Official web page (react.dev)",
"Next.js (Fullstack framework)",
"React Native (build native mobile apps with React)"
],
[
"Vanilla JavaScript requires imperative programming",
"Imperative Programming: You define all the steps needed to achieve a result",
"React on the other hand embraces declarative programming",
"With React, you define the goal and React figures out how to get there"
]
];
export default function App() {
const [activeContentIndex, setActiveContentIndex] = useState(0);
return (
<div>
<header>
<img src="react-logo-xs.png" alt="React logo" />
<div>
<h1>React.js</h1>
<p>i.e., using the React library for rendering the UI</p>
</div>
</header>
<div id="tabs">
<menu>
<button
className={activeContentIndex === 0 ? "active" : ""}
onClick={() => setActiveContentIndex(0)}
>
Why React?
</button>
<button
className={activeContentIndex === 1 ? "active" : ""}
onClick={() => setActiveContentIndex(1)}
>
Core Features
</button>
<button
className={activeContentIndex === 2 ? "active" : ""}
onClick={() => setActiveContentIndex(2)}
>
Related Resources
</button>
<button
className={activeContentIndex === 3 ? "active" : ""}
onClick={() => setActiveContentIndex(3)}
>
React vs JS
</button>
</menu>
<div id="tab-content">
<ul>
{content[activeContentIndex].map((item) => (
<li key={item}>{item}</li>
))}
</ul>
</div>
</div>
</div>
);
}