【问题标题】:mobx-state-tree Error while converting `""` to `AnonymousModel[]`mobx-state-tree 将 `""` 转换为 `AnonymousModel[]` 时出错
【发布时间】:2019-06-14 19:43:04
【问题描述】:

我收到此错误,但我不知道为什么。我正在运行 mobx 状态树(3.2.4)

:8080/main.js:52013 Uncaught (in promise) Error: [mobx-state-tree] Error while converting `""` to `AnonymousModel[]`:

    value `""` is not assignable to type: `AnonymousModel[]` (Value is not an array).
    at fail (:8080/main.js:52013)
    at typecheck$$1 (:8080/main.js:51692)
    at typecheckInternal$$1 (:8080/main.js:51678)
    at ArrayType$$1../node_modules/mobx-state-tree/dist/mobx-state-tree.module.js.ArrayType$$1.applySnapshot (:8080/main.js:52884)
    at executeAction (:8080/main.js:55058)
    at ArrayType$$1.res (:8080/main.js:55050)
    at :8080/main.js:50844
    at executeAction (:8080/main.js:55058)
    at res (:8080/main.js:55050)
    at runMiddleWares (:8080/main.js:51533)

我看不到任何迹象表明我正在尝试将空字符串设置为数组。

我如何确定它试图应用的属性是什么?

【问题讨论】:

标签: reactjs mobx mobx-state-tree


【解决方案1】:

没有代码不容易回复,但您可能正在加载data that is not following the type specification of your model
看起来你有一个空字符串而不是一个数组。


另一个常见错误是将整数用于需要字符串的types.identifier 类型的字段。

使用types.identifierNumber 获得数字ID。

【讨论】:

    猜你喜欢
    • 2021-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    • 1970-01-01
    • 2019-11-26
    • 1970-01-01
    相关资源
    最近更新 更多