Skip to content

Commit b7dbf4a

Browse files
author
최한울
committed
Use Function Component
- 기존에 배웠던 함수 컴포넌트로 변경 - App 확장자 .jsx로 변경
1 parent d9f9f82 commit b7dbf4a

File tree

2 files changed

+23
-32
lines changed

2 files changed

+23
-32
lines changed

src/App.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/App.jsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, { useState, useEffect } from 'react';
2+
3+
import './App.css';
4+
5+
function App() {
6+
const [appName, setAppName] = useState(null);
7+
8+
useEffect(() => {
9+
fetch('api/group')
10+
.then((res) => res.json())
11+
.then((data) => setAppName(data.appName));
12+
}, []);
13+
14+
return (
15+
<div className="App">
16+
<header className="App-header">
17+
{appName ? `Hello ${appName}` : 'Hello World'}
18+
</header>
19+
</div>
20+
);
21+
}
22+
23+
export default App;

0 commit comments

Comments
 (0)