You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { defineStore } from 'pinia'
const useCounterStore = defineStore('counter', {
state: () => {
return { }
},
})
export default {
setup() {
const counter = useCounterStore()
// The following line of code works fine in development mode but in production mode it throws an error that says Converting
// circular structure to JSON
// --> starting at object with constructor 'Or'
// --- property '_renderProxy' closes the circle
// at JSON.stringify (<anonymous>)
JSON.stringify(counter)
},
}
Steps to reproduce the behavior
Pinia store as a parameter to JSON.stringify
Expected behavior
When pinia store is used as an argument to JSON.stringify, there should be consistent behavior in both production and development environments
Actual behavior
When pinia store is used as a JSON.stringify parameter, it will report an error in the production environment, but everything works fine in the development environment
Additional information
The pinia store in the production environment will have an additional "_p" attribute, resulting in circular references
The text was updated successfully, but these errors were encountered:
A store isn't JSON-serializable. Only the state is (as long as you don't use circular references). I'm curious about why you were using JSON.stringify on the whole store though.
A store isn't JSON-serializable. Only the state is (as long as you don't use circular references). I'm curious about why you were using JSON.stringify on the whole store though.
My scenario is to use vue-query to query the data, he will automatically call the interface when the store changes, it is based on object serialization to serialize the store into a string to determine whether to perform a call or return a cached value
Reproduction
Steps to reproduce the behavior
Expected behavior
When pinia store is used as an argument to JSON.stringify, there should be consistent behavior in both production and development environments
Actual behavior
When pinia store is used as a JSON.stringify parameter, it will report an error in the production environment, but everything works fine in the development environment
Additional information
The pinia store in the production environment will have an additional "_p" attribute, resulting in circular references
The text was updated successfully, but these errors were encountered: