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 {
|
||||
// State is returned directly - it's already reactive in Svelte 5
|
||||
// Components can read: formStore.fields.title
|
||||
// Mutation should go through methods below for validation
|
||||
fields,
|
||||
validationErrors,
|
||||
// Use getters to maintain reactivity when accessing state from outside the store
|
||||
get fields() {
|
||||
return fields
|
||||
},
|
||||
set fields(value: ProjectFormData) {
|
||||
fields = value
|
||||
},
|
||||
get validationErrors() {
|
||||
return validationErrors
|
||||
},
|
||||
isDirty,
|
||||
|
||||
// Methods for controlled mutation
|
||||
|
|
|
|||
Loading…
Reference in a new issue