Mobx-persist-store shows up the "Converting circular structure to JSON" when I save array into the sessionstorage
MelodyFish opened this issue · 2 comments
MelodyFish commented
Console show the details:
--> starting at object with constructor 'FiberNode'
| property 'stateNode' -> object with constructor 'HTMLElement'
--- property '__reactFiber$2k3uax4tvxn' closes the circle
at JSON.stringify (<anonymous>)
at StorageAdapter.<anonymous> (StorageAdapter.js:57:1)
MelodyFish commented
Here is my mobx store code:
import { makeAutoObservable, action } from 'mobx'
import { makePersistable } from 'mobx-persist-store'
import PlatformContent from '../pages/WorkPlatform/Content'
class TabStore {
tabsList = JSON.parse(JSON.stringify([{
name: 'work',
key: '/',
url: '',
icon: <img src={require('@/assets/img/work_on.png')} width={13} />,
closable: false,
}]))
constructor() {
makeAutoObservable(this)
makePersistable(
this,
{ name: 'tabsList', properties: ['tabsList'], storage: window.sessionStorage },
)
}
setTabsList(value) {
this.tabsList = value
}
}
export { TabStore }
MelodyFish commented