React-native: when submitting a text input in android, the word suggestions are not cleared

依然范特西╮ 提交于 2019-12-07 10:39:18

问题



I have an Android app built with React native.
The app has a TextInput and a submit button.
When typing in the text input, the default keyboard starts suggesting words (not sure how this feature is called - auto complete or predictive text).
When clicking submit, the data is stored and the TextInput is cleared via the "clear()" method of the TextInput. For example:

this.refs.textInput.clear();

For some reason, the "predictive text" is not cleared after the "clear()" method is called. As a result, when the user start typing again, the predictive text continues from where it stopped and the user has to clear the text input.
Note: the text input is multi-line. Not sure if it has anything to do with the problem.

Here is example for the same issue: Example

See attached image for more details:


回答1:


I found a solution:
On submit, I change the keyboard and revert back, like in the following code.

this.refs.textInput.setNativeProps({keyboardType:"email-address"});
this.refs.textInput.setNativeProps({keyboardType:"default"});


来源:https://stackoverflow.com/questions/37798584/react-native-when-submitting-a-text-input-in-android-the-word-suggestions-are

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!