using useFieldContext with an Object
Hey, couldn't find any info on this, is this the correct/a possible way to work with objects? I know I could do
name="object.property"
, however I probably want to be able to change multiple properties of the same object in 1 component
This is my component:
And this is the Type definition:
1 Reply
fair-rose•2mo ago
of course! Objects are allowed as field values, so contexts are also allowed. Just remember the React rule of immutable objects and you‘re good to go
note that compound fields lose information about specific fields. You can no longer tell the isTouched state apart from talentName and TaW for example
Something worth checking is the error generation from the schema though … maybe it attempts mapping to object.property even though that field doesn‘t exist