Reputation: 1
I use react-native paper and I need help... I would like to know how to reject the keyboard and also how to deactivate OnFocus when onblur is active
import { View, StyleSheet } from 'react-native';
import { TextInput } from 'react-native-paper';
const Input = () => {
return (
<TextInput
style={styles.inputField}
label='Email'
mode='outlined'
/>
);
};
const styles = StyleSheet.create({
inputField: {
width: '100%',
}
})
export default Input;
Upvotes: 0
Views: 131
Reputation: 86
You can use the help of useState to achieve this below code is for reference:
const [emailError, setEmailError] = useState('');
const [passwordError, setPasswordError] = useState('');
const [focusedInput, setFocusedInput] = useState('');
<TextInput
style={[
styles.input,
focusedInput === 'email' && styles.inputFocused,
emailError && styles.inputError,
{
backgroundColor: isDarkTheme
? secondaryDarkColor
: secondaryLightColor,
marginVertical: 20,
color: isDarkTheme ? 'white' : 'black',
},
]}
placeholder="Email"
keyboardType="email-address"
placeholderTextColor={secondaryTextColor}
value={email}
onFocus={() => setFocusedInput('email')}
onBlur={() => setFocusedInput('')}
onChangeText={text => {
setEmail(text);
setEmailError('');
}}
/>
Upvotes: 0