Reactivity of state properties after an update #1391
Answered
by
posva
franck102
asked this question in
Help and Questions
-
Hi all, I am wondering if the following is a valid pattern, from the reactivity point of view, to load data from the server: export const myStore = defineStore('Booking', {
state: () => ({
items: {}
)},
actions: {
loadData() {
backend.get("/items").then(data => this.state.items = data)
}
} If a component used const { myItems } = storeToRefs(myStore); .. before loadData was called, will "myItems"still be reactive after loadData replaces the state.items property? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Jun 29, 2022
Replies: 1 comment 1 reply
-
You mean |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You mean
this.items
Instead of this.state.items ? If so, yes.