React Native MantineInputs

useForm

Form state management hook with validation

Import: import { useForm } from 'react-native-mantine';

Usage

import { useForm, isEmail, minLength, TextInput, Button } from 'react-native-mantine';

const form = useForm({
  initialValues: { email: '', password: '' },
  validate: {
    email: isEmail('Invalid email address'),
    password: minLength(6, 'Password must be at least 6 characters'),
  },
  validateInputOnBlur: true,
});

<TextInput label="Email" {...form.getInputProps('email')} />
<TextInput label="Password" secureTextEntry {...form.getInputProps('password')} />
<Button onPress={form.onSubmit((values) => console.log(values))}>Submit</Button>

Source on GitHub · npm