-
-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add react-native usage guide (#558)
- Loading branch information
1 parent
01ea65e
commit 0a6278e
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
id: react-native | ||
title: 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: | ||
|
||
```tsx | ||
<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={handleChange} /> | ||
{ | ||
field.state.meta.errors | ||
? <Text>{field.state.meta.errors.join(', ')}</Text> | ||
: null | ||
} | ||
</> | ||
)} | ||
</form.Field> | ||
``` |