Build a one-time-code input as a single React component: six separate single-character boxes, the kind an app shows after texting you a verification code. The interesting part isn't the boxes — it's the focus choreography. Typing a digit fills a box and jumps to the next; backspace walks back; pasting the whole code fans it out across all six. Managing that focus with refs (not DOM queries) is the skill under test.
The starter App.tsx renders six empty boxes and a placeholder line. Make it work:
useState(Array(6).fill('')).useRef array of the six inputs lets you focus a sibling.digits[i], then focus box i + 1.i - 1 and clear that one.Code: 123456 once all six are filled, else Code: —.4 — box 0 shows 4 and focus jumps to box 1. Type 2 — box 1 shows 2, focus moves to box 2.123456 into any box — every box fills in order and the last box takes focus. The line reads Code: 123456.0–9 only.document.querySelector. That is the whole point.digits.join('') — do not store it as separate state.styles.css; focus on the logic.