CodingNic

Build the Currency Converter

Wire the Currency Dropdowns

Build the Currency Converter 25 min read

Wire the Currency Dropdowns

Wire the Currency Dropdowns

Use the existing currencies object to render each option and connect the selected option to the page callback.

javascript
function selectCurrency(side, code) {
  onPairChange(
    side === "from" ? code : from,
    side === "to" ? code : to
  );
  setOpen(null);
}

Keep the dropdown open state local to the converter.

Test it

Open both selectors, choose several currencies, and confirm the visible flags and codes change.

Checkpoint

The dropdowns now update the shared pair without duplicating currency data.