react-verification-code-input
react-verification-code-input copied to clipboard
Checking new and previous props.values
Checking new and previous props.values; Updating state on change props.values
The component will react to the change props.values. This can be used for example to clear inputs
Example
const [code, setCode] = useState('');
const handleChange = (value) => setCode(value);
const handleResend = () => setCode('');
return (
<Fragment>
<ReactCodeInput
type="number"
fields={6}
values={code}
onChange={handleChange}
/>
<button onClick={handleResend}>Clear</button>
</Fragment>
);