Question: I was wondering what's the best approach for handling an autosubmit of a code that a user types in? I have this so far but idk if this works. I tried testing it but I wasn't performing as I expected.

```
This is the form control:

<div className="form-group">
        <input
            type="tel"
            autoComplete="one-time-code"
            maxLength="6"
            className="code-form"
            onChange={this.changeCode}
            value={code}
        />
    </div>

```

And this is the onChange event:

```
changeCode = e => {
    this.setState({ code: e.target.value });

    if(this.verificationCode.length == 6) {
      this.verifyCode(); 
    }
  };

```

If the length of what the user types in is 6, then I just want to submit it. Is this right approach?

The following code is inside a webview react project that is housed inside of react-native app.

Answer: 
There is no need to use debouncing for such small task,just check lenght of code in setState's call back and submit.

```
 changeCode = e => {
        this.setState({ code: e.target.value },()=>{
          if(this.state.code.length == 6) {
           this.verifyCode(); 
          }
         });
      };

```
You can try with throttle and debounce:

```
if (this.verificationCode.length < 5) {
    throttle(500, this.verifyCode)
  } else {
    debounce(500, this.verifyCode);
  }

```