Getting Started¶
Welcome to medhira-rn-typescript-hooks — typed React Native validation hooks for forms, selects, and checkboxes.
Installation¶
npm install medhira-rn-typescript-hooks medhira-react-typescript-hooks react react-native
# Expo
npx expo install medhira-rn-typescript-hooks medhira-react-typescript-hooks
Hooks Overview¶
| Hook | Purpose |
|---|---|
useValidateForm | Text/number input validation |
useValidateSelect | Single or multiple select validation |
useValidateCheckBox | Checkbox validation |
Quick Start¶
import { TextInput } from 'react-native';
import { useValidateForm } from 'medhira-rn-typescript-hooks';
const EmailField = () => {
const form = useValidateForm({
type: 'string',
label: 'Email',
isRequired: true,
keyboard: 'email-address',
validationPattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
});
return (
<TextInput
value={form.value ?? ''}
onChangeText={form.valueChangeHandler}
onFocus={form.valueFocusHandler}
onBlur={form.valueBlurHandler}
/>
);
};
Architecture¶
See the Architecture page for flow diagrams and package boundaries.
Requirements¶
- React 18+
- React Native 0.60+
- medhira-react-typescript-hooks >= 0.1.0 (peer dependency)