Bootstrap
Created with Create React App:
npx create-react-app converter
cd converter
yarn start
App is now running at http://localhost:3000.
Goal
We're going to make a Euro-to-$BTC converter application.
Steps
-
Add a number input with a label, "Euros".
-
Extract the input into a separate component called
<Amount />
that takes aname
(eg. "Euros") prop. -
(Optional) If it is not already, convert
<Amount />
into a class-based component. -
Teach
<Amount />
input to show a red outline for negative amounts. -
Make
<Amount />
a controlled component (ie. pass it itsvalue
as a prop). -
Add a second, read-only
<Amount />
component that shows $BTC instead of Euros; use this function to get the exchange rate:function exchangeRate() { return Math.random() * 10000; }
-
Use
setTimeout
to make the $BTC price crash to zero after 5 seconds of inactivity. -
Use
React.createContext()
to provide a dark/light theme toggle.