Skip to content
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

What part of the React lifecycle is the best place to run the code to show the keyboard? #102

Open
haveamission opened this issue Jun 14, 2019 · 3 comments

Comments

@haveamission
Copy link

I am trying to integrate this into a React app, and I am noticing that the keyboard opens, closes, and then opens again and the whole viewport resizes and looks awful.

This is when running the keyboard launch in the render() method - is there a better way to launch the keyboard in React? React Cordova apps are relatively rare and I'm not seeing many instances of how to handle this.

@EddyVerbruggen
Copy link
Owner

I have 0 React experience, so don't expect an answer from me.

@flache
Copy link

flache commented Jun 17, 2019

I call the showMessenger method in componentDidMount (so I already have the ref for the autoscrollElement) and hideMessenger in componentWillUnmount

@corncobb
Copy link

corncobb commented Sep 10, 2020

If you are using React Hooks, useEffect with nothing in the dependency array would be equivalent to componentDidMount. Use a useEffect cleanup method would be the same as componentWillUnmount.

useEffect(() => {
     // Put your show keyboard code in here
     
     return () => {
     // Put your componentWillUnmount code here
     }

}, [])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants