-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent crash when keyboard opens before text input is created #21
base: master
Are you sure you want to change the base?
Conversation
Your fixes not resolve my issue. App is now hanging. I have made the changes in RNCustomKeyboardModule.java. After Generating build my app slow down and I am not able to switch to another tab and it stop responding. Please help! Thanks |
@singhlovey can you share a bit more code around where you are seeing this hanging behaviour? I don't have any problem so far, but my colleague seems to have the same problem as you (on the same code as me). |
@singhlovey I have modified
and removed the I first tried to remove the calls to |
Okay. Let me check. Thanks |
I have made changes as suggested by you. But the thing is custom keyboard register every time when I come to the page where custom keyboard is used. Can you just provide me sample example on how you are using custom keyboard in your react native code. NOTE:- In my case if I have 10 fields on one page, then custom keyboard registered 10 times even it I have not opened custom keyboard yet. I want it to call or you can say register only when I opened the custom keyboard. I am using CustomTextinput in place of TextInput. Is there any way I can use TextInput component and when I click on input field and only then custom keyboard will open in place of android default keyboard. I have this type of fields in each tab : -
Now whenever I click on tab, each field registered as it has CustomTextInput component. I need to use TextInput inplace of CustomTextInput and call keyboard using install when click on input field or onFocus event of textInput. Thanks |
Please help me for the above. I am not able to move because of this. Thanks |
Hi I am able to fix the issue for android app. Now I am implementing the same for iOS app. Can you just provide me some hints on how to integrate on iOS app. I have implemented all the things but when I try to open the custom keyboard app crashes or hang and not works. Please help! Thanks |
@singhlovey Great news if it works for you on android. Can you share your solution? |
index.js file import React, { Component } from 'react'; import {
const keyboardTypeRegistry = {}; export function register(type, factory) { class CustomKeyboardContainer extends Component { render() {
} AppRegistry.registerComponent("CustomKeyboard", ()=>CustomKeyboardContainer); export class CustomTextInput extends Component {
}
componentDidMount() { componentWillReceiveProps(newProps) { My project folder file where I am using custom keyboard <CustomTextInput customKeyboardType="hello" selectTextOnFocus={ true } The above code did trick for me. This is temporary solution but I have only this way to do for android. now I am not getting any crash as I am installing custom keyboard only when user click on input field. I have used onKeyPress in place of onFocus as we cannot use onFocus two times because it is on same file. Please let me know if any doubt. |
Fixes #20.
The crash seems to be due to the keyboard trying to find the native input component before it's created. This PR fixes this by catching exceptions and retrying until it finds the input. In most cases, this shouldn't slow down anything noticeably.