chobo2
chobo2

Reputation: 85785

mobx-state-tree Error while converting `""` to `AnonymousModel[]`

I am getting this error but I don't know why. I am running mobx state tree (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)

I cannot see any indication I am trying to set an empty string to an array.

How can I pinpoint what property it is trying to apply?

Upvotes: 2

Views: 6068

Answers (1)

Guglie
Guglie

Reputation: 2451

Not easy to reply without code, but probably you're loading data that is not following the type specification of your model.
It seems you have an empty string instead of an array.


Another common mistake is to use an integer for a field of type types.identifier which expects a string.

Use a types.identifierNumber to have numerical ids.

Upvotes: 2

Related Questions