I have an array of objects and use indexOf to find a specific object in that array.
I have switched to an online datastore and because the data for a selected object is now returned as variables I have to create a "dummy" object that is then used to look up the matching selected object in the array.
I have compared the dummy object and the object in the array and they look identical however null is always returned.
This is the array of objects:
data:
[
Creative {
id: '5631943370604544',
gid: '5631943370604544',
name: 'Hello',
description: '',
url: '',
videos: []
},
Creative {
id: '5653294995210240',
gid: '5653294995210240',
name: 'Yo',
description: '',
url: '',
videos: []
},
Creative {
id: '5745189578604544',
gid: '5745189578604544',
name: 'Sup',
description: '',
url: '',
videos: []
}
]
This is the dummy object:
object:
Creative {
id: '5653294995210240',
gid: '5653294995210240',
name: 'Yo',
description: '',
url: '',
videos: []
}
Here is the function that is used for the look up. This is unmodifiable as it is part of GraphQL and Relay and it is the function that is used.
function cursorForObjectInConnection(data, object) {
var offset = data.indexOf(object);
if (offset === -1) {
return null;
}
return offsetToCursor(offset);
}