Add preact integration for tanstack form#2043
Add preact integration for tanstack form#2043JoviDeCroock wants to merge 7 commits intoTanStack:mainfrom
Conversation
|
|
View your CI Pipeline Execution ↗ for commit 3568d4f
☁️ Nx Cloud last updated this comment at |
theVedanta
left a comment
There was a problem hiding this comment.
compat and use-client are the only things I wanna flag, since they're in multiple files. Apart from that, looks okay. The onInput prop isn't important as such, but would be a nice-to-have.
| Field: FieldComponent< | ||
| TFormData, | ||
| TOnMount, | ||
| TOnChange, |
There was a problem hiding this comment.
I feel like fields should have an onInput prop instead of onChange for it to be consistent with Preact. If we can do that, it'd be awesome
There was a problem hiding this comment.
I don't think anyone would benefit from that, the end-user is still free to use onInput in exchange for onChange at their disposal
There was a problem hiding this comment.
Oh, gotcha. But how would users use onInput in parts of the API that are not the children?
<form.Field
name="firstName"
validators={{
onInput: ({ value }) =>
!value
? 'A first name is required'
: value.length < 3
? 'First name must be at least 3 characters'
: undefined,
}}
...I can understand if you feel like they don't, I was only thinking about it because of consistency with Preact's naming.
There was a problem hiding this comment.
Ah I see what you mean now, sorry I didn't derive the validator enforcement from the comment
There was a problem hiding this comment.
Validators should use onChange even on adapters that use onInput. That comes from core. No need to change :)
theVedanta
left a comment
There was a problem hiding this comment.
Once we can finalize this, let's get the docs in place and merge! Super excited to use preact-form 🔥
| Field: FieldComponent< | ||
| TFormData, | ||
| TOnMount, | ||
| TOnChange, |
There was a problem hiding this comment.
Oh, gotcha. But how would users use onInput in parts of the API that are not the children?
<form.Field
name="firstName"
validators={{
onInput: ({ value }) =>
!value
? 'A first name is required'
: value.length < 3
? 'First name must be at least 3 characters'
: undefined,
}}
...I can understand if you feel like they don't, I was only thinking about it because of consistency with Preact's naming.
🎯 Changes
@tanstack/preact-formpackage to the monorepo.@tanstack/preact-storeinstead of@tanstack/react-store.useIdfrompreact/hooksfor form ID generation.preactpeer dependency to>10.11.0for useId support.