-
Notifications
You must be signed in to change notification settings - Fork 121
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
Typescript support for custom fieldConfig props #115
Comments
In other words I got it working for the fieldconfig function used in the schema with the below type, but not with the fieldwrapper type. type FieldConfig<T, U> = BaseFieldConfig<T, U> & {
topDescription?: React.ReactNode;
}; |
I'll add support for a import { buildZodFieldConfig } from "@autoform/react";
import { FieldTypes } from "./AutoForm";
export const fieldConfig = buildZodFieldConfig<
FieldTypes,
{
isImportant?: boolean
}
>();
const zodFormSchema = z.object({
username: z
.string()
.superRefine(
fieldConfig({
customData: {
isImportant: true,
},
})
), |
It did work to just add it to the default field props, but typescript is complaining. Also a random question, since you are using react-hook-form under the hood, is this something you want to move away from or do you want to use it? I think it is smart to use it |
In the rewrite I wanted to remove the dependency on react-hook-form so it's currently not used. But I see now that it doesn't make sense to implement that functionality manually, so I will switch to using react-hook-form again in the next release! |
@vantezzen I think in general it is a bad idea to try to circumvent |
How do I get this working now that I have updated to V2, v2.1 is not available on npm yet |
I think this problem can be addressed with this issues #124 |
I think there was a problem generating the new version - it should now be live |
I created a FieldWrapper, with a custom
topDescription
prop on the fieldConfig as seen below. But I get type errors that it does not exist on fieldConfig, and I was wondering how to fix it. I tried adding it to the fieldconfig type that is used in the fieldconfig function but that did not fix it, probably because it is imported from autoform/react. How can I fix this issue?The text was updated successfully, but these errors were encountered: