Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme with video #122

Merged
merged 2 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Fewer renders, better performance and no weird "intermediary states".

### 🔍 Optimized for flexibility

While Yup is supported, you're not limited to using a large Yup schema. Validation functions receive the form state as well as the field value.
While Yup is supported, you're not limited to using a single large Yup schema. Validation functions receive the form state as well as the field value.

```tsx
(value, state) =>
Expand Down Expand Up @@ -94,22 +94,17 @@ return <FielderProvider value={myForm}>{children}</FielderProvider>;
`useField` is where you harness the power of _Fielder_.

```tsx
const [nameProps, nameMeta] = useField({
name: 'userName',
validate: useCallback(
v =>
Yup.string()
.required()
.validateSync(v),
[]
)
const [usernameProps, usernameMeta] = useField({
name: 'username',
initialValue: 'fielder-user',
validate: validateUsername
});

return (
<>
<input type="text" {...nameProps} />
{nameMeta.hasChanged && nameMeta.error && (
<ErrorMsg>{nameMeta.error}</ErrorMsg>
<input type="text" {...usernameProps} />
{usernameMeta.hasChanged && usernameMeta.error && (
<ErrorMsg>{usernameMeta.error}</ErrorMsg>
)}
</>
);
Expand All @@ -124,8 +119,11 @@ There are a whole number of additional arguments which can be passed to `useFiel

> Note: Unlike other popular form libraries, _Fielder_ allows you to change config options (such as validation) at any time.

## Resources
## Additional resources

For more info, tutorials and examples, visit the **[official docs site](https://fielder.andyrichardson.dev/)**!

For more info and examples, check out the **[official docs site](https://fielder.andyrichardson.dev/)**.
Also check out:

For a deeper dive on Fielder and why it exists, check out [this blog post](https://dev.to/andyrichardsonn/why-we-need-another-form-library-fielder-4eah).
- [[Article] Why we need another form library](https://dev.to/andyrichardsonn/why-we-need-another-form-library-fielder-4eah)
- [[Video] Getting started with Fielder](https://www.youtube.com/watch?v=wSorSlCkJwk)
13 changes: 8 additions & 5 deletions docs/src/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,18 @@ return <FielderProvider value={myForm}>{children}</FielderProvider>;
`useField` is where you harness the power of _Fielder_.

```tsx
const [nameProps, nameMeta] = useField({
name: 'userName',
validate: useCallback((v) => Yup.string().required().validateSync(v), []);
const [usernameProps, usernameMeta] = useField({
name: 'username',
initialValue: 'fielder-user',
validate: validateUsername
});

return (
<>
<input type="text" {...nameProps} />
{nameMeta.hasChanged && nameMeta.error && <ErrorMessage>{nameMeta.error}</ErrorMessage>}
<input type="text" {...usernameProps} />
{usernameMeta.hasChanged && usernameMeta.error && (
<ErrorMsg>{usernameMeta.error}</ErrorMsg>
)}
</>
);
```
Expand Down