0
Fork 0
mirror of https://github.com/TanStack/form.git synced 2026-11-18 07:36:42 +00:00
form/docs/framework/react/guides/react-native.md
LeCarbonator 443d270bfa
feat(form-core): add <FieldMeta>.isValid (#1422)
* feat(form-core): add <FieldMeta>.isValid

this is a shortened counterpart to checking
field.state.meta.errors.length > 0

* docs: use isValid checks instaed of error length checks

* fix: read field derived data from the right store

* style: revert extracting errorMap variable in setMeta

* style: revert extracting errorMap variable in setFieldMeta

* docs: rephrase isValid description and related props

---------

Co-authored-by: Leonardo Montini <lion.48m@gmail.com>
Co-authored-by: Luca <luca@luca-laptop.int.dr-jakob.ch>
2025-04-29 12:21:58 +02:00

608 B

id title
react-native Usage with React Native

TanStack Form is headless and it should support React Native out-of-the-box without needing any additional configuration.

Here is an example:

<form.Field
  name="age"
  validators={{
    onChange: (val) =>
      val < 13 ? 'You must be 13 to make an account' : undefined,
  }}
>
  {(field) => (
    <>
      <Text>Age:</Text>
      <TextInput value={field.state.value} onChangeText={field.handleChange} />
      {!field.state.meta.isValid && (
        <Text>{field.state.meta.errors.join(', ')}</Text>
      )}
    </>
  )}
</form.Field>