parse-community / ParseReact

Seamlessly bring Parse data into your React applications.
https://parseplatform.org
Other
1.3k stars 209 forks source link

Getting lots of "Attempted to flatten something that is not a Parse Object" #117

Open 0x0ece opened 9 years ago

0x0ece commented 9 years ago

Since ParseReact 0.5 (but maybe also 0.4.x) I'm getting a lot of warnings "Attempted to flatten something that is not a Parse Object".

I suspect this happens on models with a filed of type Array that contains (json) objects. So like model Person, with field sons of type Array, and the actual value of John.sons = [{"name": "John Jr."}, ... ]

richarmstrong commented 9 years ago

I've been getting this since the beginning of my project 2 months ago, so it does apply to 0.4.x. I, too, am using an object that has an Array field with json values, so that seems to be the right path.

andyyou commented 9 years ago

Is that mean I can't use Array type field and equalTo method that Queries on Array Values in official documents

kkarimi commented 9 years ago

This is happening to me with models without array type.

mmazzarolo commented 8 years ago

Any news about this issue? I'm still getting the warning "Attempted to flatten something that is not a Parse Object" on String arrays.

Edit: To me it seems that the problem is in flatten.js: mappedFlatten(el) tries to flatten every element of the array (by calling flatten(el)), even if they are not Parse Objects.

lrettig commented 8 years ago

+1. I have objects with arrays of strings. Why is this producing a warning? Thanks.

richarmstrong commented 8 years ago

I had an array of objects in one Parse model. They looked like this: [{"date":"2012-09-09","note":"foo"},{"date":"2012-09-08","note":"bar"}]

I removed this data to its own Parse object and the error went away. Later, it resurfaced on another object that has a straight array of strings:

["foo","bar"]

I think the note above that someone was able to make this error happen without an array in their objects is maybe a red herring. This error is clearly heavily associated with this kind of object attribute. It might also be associated with some other condition, but that's somewhat immaterial to chasing down the most frequent cause.

mmazzarolo commented 8 years ago

If you're interested I added a pull request with a fix that is working (at least for me, need someone to confirm)... https://github.com/ParsePlatform/ParseReact/pull/157

lrettig commented 8 years ago

Thanks @mmazzarolo, your change looks correct to me.