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

[@mantine/form] add asyncResolver on use-form #1255

Conversation

auronsan1st
Copy link
Contributor

@auronsan1st auronsan1st commented Apr 15, 2022

#1100

to check promise need call function ex schema(null) I think there will be performance loss on other resolver ex: yup, zoi. so I decided just use asyncResolver props.

my suggest to make not bigger code should split between async and sync so no hidden bug will occur.
the schema types depend on many place. so I can't change to use Promise. for now I just bypass it by any when init useForm

Copy link
Member

@rtivital rtivital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, I do not really like what I'm seeing, async api feels very strange and unintuitive.

@@ -0,0 +1,97 @@
import { renderHook, act } from '@testing-library/react-hooks';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests files should be in tests folder.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's test helper async version of src/mantine-form/src/resolvers/test-resolver.ts

src/mantine-demos/src/demos/form/Form.demo.zod.tsx Outdated Show resolved Hide resolved
@auronsan
Copy link

auronsan commented Apr 15, 2022

Currently, I do not really like what I'm seeing, async api feels very strange and unintuitive.

yeah I feel same. but if can need support it right. actually if #1100
they can check theirselves and throw error when trigger on submit. I don't why checking use schema + API request

@rtivital
Copy link
Member

Alright, I think this issue will require more investigation before it can be merged, getting the api right for these use cases seems to be tricky

@auronsan
Copy link

auronsan commented Apr 20, 2022

@rtivital I think the approach can be similar like this.
https://github.com/react-hook-form/resolvers

resolver(schema: object, schemaOptions?: object, resolverOptions: { mode: 'async' | 'sync' })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants