From 398e6c8b6fec9abfb2e421ecbc967a4c66c6a122 Mon Sep 17 00:00:00 2001 From: Pavel Date: Thu, 10 Nov 2022 15:31:03 +1000 Subject: [PATCH] feat: add remove last char on Backspace pressed --- index.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.tsx b/index.tsx index 6c56ef8..e5b4c3f 100644 --- a/index.tsx +++ b/index.tsx @@ -152,6 +152,12 @@ export default class OTPInputView extends Component 0) { this.handleChangeText(index - 1, '') + const digits = this.getDigits(); + const newdigits = digits.slice(); + + this.setState({ + digits: newdigits.map((item, i) => (i === index - 1 ? "" : item)), + }); this.focusField(index - 1) } }