You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interface Address {
street: string
houseNumber: number
city: string
country: string
}
interface Person {
name: string
address: Address
}
interface Order {
item: string
shippingAddress: Address
}
I wanna create component to display Address part of any form.
So that in other forms(like Order and Person and many more which will have address field structure) I can declaratively reuse Address fields by just providing basePath to them and having correct typescript validation and typings.
The text was updated successfully, but these errors were encountered:
@LeCarbonator yep, seems like what i asked for. Thank you! But still would be good to have an api as simple and flexible at the same time as possible. Like react hook form lenses has. They have lens.reflect(...) for example which allows to map fields with different names to the fields which nested lense part expects. And for now RHF lenses api seems just simpler and more flexible as i see.
But overall yes, this is the direction i was asking for
@LeCarbonator yep, seems like what i asked for. Thank you! But still would be good to have an api as simple and flexible at the same time as possible. Like react hook form lenses has. They have lens.reflect(...) for example which allows to map fields with different names to the fields which nested lense part expects. And for now RHF lenses api seems just simpler and more flexible as i see.
But overall yes, this is the direction i was asking for
I see! Perhaps there's a way to implement that. As it is right now, the reason the mapping wasn't supported is because validation can simply be inherited from the field instead of requiring reflection on all properties.
Would be good to have ability to compose set of fields to different forms that have same common field using typescript.
react-hook-form
already has such functionality via Lenses: https://github.com/react-hook-form/lensesOriginal feature request which ended up by creating lenses for
react-hook-form
: https://github.com/orgs/react-hook-form/discussions/7354Overview
Imagine this structure of forms:
I wanna create component to display
Address
part of any form.So that in other forms(like
Order
andPerson
and many more which will have address field structure) I can declaratively reuseAddress
fields by just providing basePath to them and having correct typescript validation and typings.The text was updated successfully, but these errors were encountered: