fix store reactivity with getter/setter
fields was losing reactivity when passed to child components. use getter/setter to maintain proxy reference.
This commit is contained in:
parent
640a0d1c19
commit
b7b5b4b4e3
1 changed files with 10 additions and 5 deletions
|
|
@ -46,11 +46,16 @@ export function createProjectFormStore(initialProject?: Project | null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// State is returned directly - it's already reactive in Svelte 5
|
// Use getters to maintain reactivity when accessing state from outside the store
|
||||||
// Components can read: formStore.fields.title
|
get fields() {
|
||||||
// Mutation should go through methods below for validation
|
return fields
|
||||||
fields,
|
},
|
||||||
validationErrors,
|
set fields(value: ProjectFormData) {
|
||||||
|
fields = value
|
||||||
|
},
|
||||||
|
get validationErrors() {
|
||||||
|
return validationErrors
|
||||||
|
},
|
||||||
isDirty,
|
isDirty,
|
||||||
|
|
||||||
// Methods for controlled mutation
|
// Methods for controlled mutation
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue