Junior — Senior
Currency exchange React component
livecode
Task condition
It is necessary to implement a React component that represents two interconnected input fields — for rubles (RUB) and dollars (USD) — as well as a toggle button ("<->") between them.
- When entering a value in the first field (RUB), the value in the second (USD) is automatically recalculated. For example, entering 150 in the RUB field should display 1 in the USD field.
- When clicking the toggle button, the fields swap positions: RUB becomes the second, and USD becomes the first. The second field then becomes disabled for input.
- The exchange rate may vary depending on the direction of exchange: 150 RUB may correspond to 1 USD, while 1 USD may equal, say, 75 RUB.
It is required to ensure correct synchronization of values and proper locking of the field after changing the direction.