Cannot read properties of undefined (reading 'length') when clearing input
sophielevens opened this issue ยท 2 comments
React-simple-keyboard version
Version 3.4.191
Describe the bug
When backspace is pressed I get an error that says Cannot read properties of undefined (reading 'length')
. I can see that the error comes from react-simple-keyboard
's node modules so wanted to ask if you know what's causing it?
It might be that i am setting the inputs incorrectly when backspace is pressed, but I'd really appreciate if you could take a look ๐
Code sandbox here - please note that the styles aren't working on the sandbox (not sure why).
Many thanks for the upkeep of this repo ๐ช
Screenshots
If applicable, add screenshots to help explain your problem.
Screen.Recording.2022-08-25.at.15.45.17.mov
Hey @sophielevens, yes this is definitely caused by the logic in the onKeyPress
, because if you comment that out the error is gone.
This is the best I could do to fix it with the time I had:
https://codesandbox.io/s/busy-keller-3lymw6?file=/src/keyboard.tsx
It's still not the best but I'm sure you can take it from there.
Some tips:
- use
debug={true}
&console.log
the keyboard properties such askeyboard.current.input
andkeyboard.current.options.inputName
. - simple-keyboard keeps it's own internal state, so make sure to compare it with your local state (this goes with the previous comment).
Cheers,
Francisco Hodge
@hodgef thanks so much for your speedy reply and taking a look ๐