如何将 Mobx 可观察对象转换为字符串

How could I convert a Mobx observable object into a string

我正在使用 Mobx 创建可观察状态。

这是我的代码片段:

window.sessionStorage.setItem(createKey(key), JSON.stringify(state))

在上面的代码中,'state' 对象是可观察的。 当我尝试将其转换为字符串时,出现错误:

error:Cannot read property 'atom' of undefined

使用JSON.stringify(mobx.toJS(state))