react-verification-code-input icon indicating copy to clipboard operation
react-verification-code-input copied to clipboard

Checking new and previous props.values

Open andreizanik opened this issue 3 years ago • 0 comments

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>
  );

andreizanik avatar Mar 09 '21 09:03 andreizanik