Tech Challenge
2026-09-09
⚛️
Daily Tech Challenge
React
medium
Question 1 of 5
Each radio is controlled by the same piece of state. The user clicks the PayPal radio once. What actually drives the selection here, and what is the shared name attribute doing?
Example
function PayMethod() {
const [method, setMethod] = useState('card');
const radio = (v) => (
<input
type="radio"
name="pay"
value={v}
checked={method === v}
onChange={(e) => setMethod(e.target.value)}
/>
);
return (
<form>
<label>{radio('card')} Card</label>
<label>{radio('paypal')} PayPal</label>
<p>{method}</p>
</form>
);
}Wednesday, September 9, 2026 · A new challenge drops every day