Build a "copy" button as a single React component. Next to a read-only code snippet sits a button; clicking it writes the snippet to the system clipboard and, for a beat, confirms it worked by flipping its label to Copied! before reverting to Copy. The write goes through the async Clipboard API, and the confirmation is a small piece of transient state on a timer.
The starter App.tsx renders the snippet and a Copy button in its resting state. Make it interactive:
copied boolean with useState(false).navigator.clipboard.writeText(text). It returns a Promise, so make the handler async and await it (or chain .then). On success, set copied to true.copied is true, add the copied class and show Copied!. Start a setTimeout that flips copied back to false after 2000ms.useRef and clear the previous one on each click, so a second click restarts the 2s window instead of an old timer resetting the label early.npm install uiready with a grey Copy button. Clicking it copies the text; the button turns green and reads Copied!.Copy.writeText is async. It returns a Promise; only mark copied after it resolves, so the confirmation reflects a real success.copied — don't track them separately.copied state) is already in styles.css; focus on the state and the timer.