#useForm + props not reactive
1 messages · Page 1 of 1 (latest)
That's correct, the form isn't reactive by design. It's just initialized with those values
I have tried wrapping it with reactive but that didn't work either
customer: props.subscription ? props.subscription.customer : null
}));```
That's just not how it works. That's not how any of this works.
You've stripped all reactivity you seem to want to check before trying to make it reactive again (which the form already does, on a non-reactive clone of the data, so properties on the form can be reactive to the UI layer).
The form isn't reactive on props tho, as I mentioned, it initializes with those values. If those props change, the form won't be updated, so it wouldn't take updated values from props.subscription in this case
If you want to store the customer only for the purpose of sending it along to the back end, see the transform method to tack it on right at the last moment.
But at the end of the day, the form is not meant to be holding computed references, it's meant to be a bundle of normal mutable references for a user to be editing via a HTML form of sorts.
If you for some reason want it to be something someone can override, but then still be overridden if the component's props change, a normal ref is probably the best idea, then use a watch on the props to override it. Use the transform method on the form to tack it onto the payload sent.
Yea, I just double checked the code again, the returned form object is literally a reactive object, but useForm is explicitly not reactive it's self. It strips off all possible reactive state in a deep clone to setup the form's default values. Not sure what @austere field wants to do this for, but it's seems to be an XY problem to me.