Xử lý input trong React Native như thế nào?
Xử lý input trong React Native như thế nào?
Xử lý input bằng TextInput theo mô hình controlled component: giá trị lưu trong state.
function LoginForm() {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const passRef = useRef<TextInput>(null);
return (
<View>
<TextInput
value={email}
onChangeText={setEmail}
placeholder="Email"
keyboardType="email-address"
autoCapitalize="none"
autoComplete="email"
returnKeyType="next"
onSubmitEditing={() => passRef.current?.focus()}
/>
<TextInput ref={passRef} value={password} onChangeText={setPassword}
secureTextEntry textContentType="password" />
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.