🖥️Frontend/React

React - 7 Coin Tracker

비엔 Vien 2025. 3. 17. 02:00
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;