코드네임 :
React - 7 Coin Tracker 본문
import { useState, useEffect } from "react";
function App() {
const [loading, setLoading] = useState(true);
const [coins, setCoins] = useState([]);
useEffect(() => {
.then((response) => response.json())
.then((json) => {
setCoins(json);
setLoading(false);
});
}, []);
return (
<div>
<h1>The Coins! {loading ? "" : `(${coins.length})`}</h1>
{loading ? <strong>Loading...</strong> : null}
<select>
{coins.map((coin) => (
<option>
{coin.name} ({coin.symbol}) : {coin.quotes.USD.price} USD
</option>
))}
</select>
</div>
);
}
export default App;
'🖥️Frontend > React' 카테고리의 다른 글
React - 6 ToDoList (0) | 2025.03.17 |
---|---|
React - 5 useEffect (0) | 2025.03.16 |
React -4 Props (0) | 2025.03.15 |
React -3 State (0) | 2025.03.11 |
React -2 (0) | 2025.03.11 |