How can I clear already written code?
If the activation code is wrong, I would like to clear the written code. I put "value" variable to props. And set the "value" to "" if the activation code is wrong. But it's not working.
"value" is working for only first time, seems it works like defaultValue.
Please help me to clear already written code. Thank you.
I'm also curious how to clear text.
Duplicate: https://github.com/40818419/react-code-input/issues/69
i made some updates to support this feature request. here’s a very simple example where the reset is triggered by a “Clear” button:
function Clearable() {
const [value, setValue] = React.useState(null);
return (
<React.Fragment>
<ReactCodeInput onChange={() => setValue(null)} value={value} />
<button onClick={() => setValue('')}>Clear</button>
</React.Fragment>
);
}
you can try it out via npm i @acusti/react-code-input or yarn add @acusti/react-code-input