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

How can I clear already written code?

Open blockfan7 opened this issue 4 years ago • 3 comments

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.

blockfan7 avatar Apr 28 '21 21:04 blockfan7

I'm also curious how to clear text.

rmlevangelio avatar Jun 06 '21 11:06 rmlevangelio

Duplicate: https://github.com/40818419/react-code-input/issues/69

rmlevangelio avatar Jun 06 '21 11:06 rmlevangelio

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

acusti avatar Oct 15 '21 01:10 acusti