nikolaiwarner / react-native-text-input-reset

A temporary hack around a bug found in some android keyboards so that the contents of a TextInput can be properly cleared.
25 stars 13 forks source link

Occur error "Attempt to invoke virtual method 'double java.lang.Double .doubleValue' on a null object reference" #6

Open nickngn opened 6 years ago

nickngn commented 6 years ago

I was trying to use your package to solve my issue: the text is duplicated when input in some Samsung devices. I declare a in constructor: image Then, I call it in a function: image And use your function to reset in conponentDidMount(): image But when I run project, it invokes the error: screenshot_20180611-150912

Hope you reply me soon.. :))

FLGMwt commented 6 years ago

I encountered the same error but not for the same reason. I found it by noticing that the response of findNodeHandle was null, instead of a number. Probably, react-native-text-input-reset should do some validation.

In your case, I think you want to make sure you're actually saving the ref of the TextInput instead of using the element as a value:

<TextInput
  ref={inputRef => { this.inputRef = inputRef; }}
  // ...
/>
// ...
TextInputReset.resetKeyboardInput(findNodeHandle(this.inputRef));
nikolaiwarner commented 6 years ago

Hi! I'm no longer maintaining this since the issue for my apps was solved in more recent versions of React Native. However, I'd be happy to merge a pull request and update npm if there's a fix for the issue.

nikolaiwarner commented 6 years ago

Hmmm, looking back at the issues over in React Native it seems that it really hasnt been solved for a lot of devices. So yeah, if this package can still provide a workaround I'll be happy to merge PRs. 😄

https://github.com/facebook/react-native/issues/19036