mobx-state-tree在将`“”转换为`AnonymousModel []时出错

时间:2019-06-14 19:43:04

标签: reactjs mobx mobx-state-tree

我收到此错误,但不知道为什么。我正在运行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)

我看不到任何尝试将空字符串设置为数组的指示。

如何确定要应用的属性?

1 个答案:

答案 0 :(得分:0)

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


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

使用types.identifierNumber来获取数字ID。