-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Realm.Results.map is not a function? #2001
Comments
I just found a workaround this issue. Instead of using
An implementation of map or forEach methods would be a great plus. |
Given that I have found a solution I will close the issue. |
@kneth is this a RN bug? I am fairly certain we've used |
Well, it could be. I have noticed that running the same code on Simulator + Debugger and on a real iOs device sometimes give me different results. Anyway on RN it didn't work for me in any of the cases. Maybe this issue is something to be looked on. Should I reopen it? |
Yes, let's check it out. |
Quick update, it seems on React Native it is possible to use .map or .forEach methods like this: |
I think it is related to https://medium.com/@jordan_mohi/cant-find-variable-symbol-in-react-native-782489d86bd7 |
I am facing this exact issue in RN 0.58.6 and above,It was working fine in RN 0.57.8 and below |
Confirming this problem for react-native@0.55.3 |
Also see this with Realm.List, not just Realm.Results. |
Just to be clear, this is still an issue. When you search for realm node foreach, this comes up on the first page. If you check all the methods that should be available on the object using (taken from SO) const getMethods = obj => {
let properties = new Set();
let currentObj = obj;
do {
Object.getOwnPropertyNames(currentObj).map(item => properties.add(item));
} while ((currentObj = Object.getPrototypeOf(currentObj)));
return [...properties.keys()].filter(item => typeof obj[item] === 'function');
};
console.log(getMethods(resultsObject)); This will tell you that forEach should be on that object, but trying to actually call it returns not a function |
We've spotted the same error on our Electron app. I know Realm does not currently support Electron, but maybe this is not an RN-only issue? |
It can be related to #1096. |
We believe this is fixed by v12. Please reopen or create a new issue if it is still a problem. |
Goals
I did query a Realm collection
Expected Results
I expect to be able to execute
.map()
or.forEach()
methods on Realm results.Actual Results
When I console.log() the realm results I see well that the type of the object is a result.
But when I do try to execute
.map()
method on it I get the following error:TypeError: schedules.map is not a function
Code Sample
Version of Realm and Tooling
2.15.3
RN: 0.56.0
Mac OSx
The text was updated successfully, but these errors were encountered: