const React = window.React; const {useState} = React; async function defer(timeoutMS) { return new Promise(resolve => { setTimeout(resolve, timeoutMS); }); } export default function FormActions() { const [textValue, setTextValue] = useState('0'); const [radioValue, setRadioValue] = useState('two'); const [checkboxValue, setCheckboxValue] = useState([false, true, true]); const [selectValue, setSelectValue] = useState('three'); return (
{ await defer(500); }} onReset={() => { setTextValue('0'); setRadioValue('two'); setCheckboxValue([false, true, true]); setSelectValue('three'); }}>
type="text" setTextValue(event.currentTarget.value)} />
type="radio" setRadioValue('one')} /> setRadioValue('two')} /> setRadioValue('three')} />
type="checkbox" { const checked = event.currentTarget.checked; setCheckboxValue(pending => [checked, pending[1], pending[2]]); }} /> { const checked = event.currentTarget.checked; setCheckboxValue(pending => [pending[0], checked, pending[2]]); }} /> { const checked = event.currentTarget.checked; setCheckboxValue(pending => [pending[0], pending[1], checked]); }} />
select
); }