I am trying to use npm i react-native-login-screen
but it is not working. When I start typing password or email the keyboard disappears, this error occurs only when I try to handle password or email state.
Here is my code:
import {View, Text} from 'react-native';
import React, {useState} from 'react';
import LoginScreen, {SocialButton} from 'react-native-login-screen';
const App = () => {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
return (
<LoginScreen
logoImageSource={require('./data1.jpg')}
onLoginPress={() => {}}
onSignupPress={() => {}}
onEmailChange={(email) => {
setEmail(email);
}
}
onPasswordChange={(password) => {
setPassword(password)
}
}
/>
);
};
export default App;
2
Answers
I had the same experience recently. I figured that useState is not working with it properly for some reason.
It does behave as expected when using useRef instead.
Here’s how I’d do it:
I am the author of this library. Version 5 is released and it fixes all these bugs and integrated more built-in features.
react-native-login-screen
You can use with the
useState
as expected now 🙂 Please try it out, here is the example: