Skip to content

TypeError: 'set' on proxy: trap returned falsish for property 'X'Β #1026

@michealroberts

Description

@michealroberts

I have the following store defined:

import { defineStore } from 'pinia'

export const useProductsStore = defineStore('products', {
  state: () => ({
      products: [] as Product[]
  }),

  getters: {
    products: (state) => state.products
  },

  actions: {
    setProducts(products: Product[]) {
      this.products = products
    }
  }
})

Let's say I have my productStore defined in setup as follows:

const productStore = useProductsStore()

When I essentially call productStore.setProducts([]), I see this bizarre error.

(FWIW, the products are coming back from an API as blank)

Expected behavior

No error, I should be able to set my products to an empty array without issue.

Actual behavior

I see the following error:

index.ts:16 Uncaught (in promise) TypeError: 'set' on proxy: trap returned falsish for property 'products'

Additional information

pinia version 2.0.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions