Composition API: Why are nested properties of objects in state readonly? #1124
-
I have a simple store written using the Composition API (/w Typescript) which holds a list of persons: export const usePersonStore = defineStore("personStore", () => {
const state = reactive({
personList: [] as Person[]
})
const addPerson = (person: Person) => {
state.personList.push(person)
}
return {
personList,
addPerson
}
}) However, simply calling
The problem is not limited to the array itself. The persons' properties in the array also cannot be modified. E.g. doing Edit: Just a side note: completely re-initializing the entire array works though, e.g. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Ok, my bad. I am using the Apollo GraphQL Client in the project and I assign the result of a GraphQL query to |
Beta Was this translation helpful? Give feedback.
Ok, my bad. I am using the Apollo GraphQL Client in the project and I assign the result of a GraphQL query to
state.personList
, thus making it readonly, since query results are immutable in Apollo Client 3.Case closed.