{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-js/issues/1933","repository_url":"https://api.github.com/repos/realm/realm-js","labels_url":"https://api.github.com/repos/realm/realm-js/issues/1933/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-js/issues/1933/comments","events_url":"https://api.github.com/repos/realm/realm-js/issues/1933/events","html_url":"https://github.com/realm/realm-js/issues/1933","id":342950383,"node_id":"MDU6SXNzdWUzNDI5NTAzODM=","number":1933,"title":"TypeError:undefined is not a function(evaluating'_realm2.default.open(databaseOptions)')","user":{"login":"Adokiye","id":38386612,"node_id":"MDQ6VXNlcjM4Mzg2NjEy","avatar_url":"https://avatars2.githubusercontent.com/u/38386612?v=4","gravatar_id":"","url":"https://api.github.com/users/Adokiye","html_url":"https://github.com/Adokiye","followers_url":"https://api.github.com/users/Adokiye/followers","following_url":"https://api.github.com/users/Adokiye/following{/other_user}","gists_url":"https://api.github.com/users/Adokiye/gists{/gist_id}","starred_url":"https://api.github.com/users/Adokiye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Adokiye/subscriptions","organizations_url":"https://api.github.com/users/Adokiye/orgs","repos_url":"https://api.github.com/users/Adokiye/repos","events_url":"https://api.github.com/users/Adokiye/events{/privacy}","received_events_url":"https://api.github.com/users/Adokiye/received_events","type":"User","site_admin":false},"labels":[{"id":643640187,"node_id":"MDU6TGFiZWw2NDM2NDAxODc=","url":"https://api.github.com/repos/realm/realm-js/labels/O:User","name":"O:User","color":"006b75","default":false},{"id":247475514,"node_id":"MDU6TGFiZWwyNDc0NzU1MTQ=","url":"https://api.github.com/repos/realm/realm-js/labels/T:Help","name":"T:Help","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-20T02:23:02Z","updated_at":"2018-07-23T16:33:48Z","closed_at":null,"author_association":"NONE","body":"\r\nI have a js file where I declared my schemas, the database options and functions that insert data, query data from the schema.\r\n\r\nI am running the app on an android emulator, anytime I try to insert data it always comes back with this error `TypeError:undefined is not a function(evaluating'_realm2.default.open(databaseOptions)')` , can anyone please help, I've been stuck on it for days :(\r\n\r\n**ALLSCHEMAS.JS**\r\n\r\n    import Realm from 'realm';\r\n    export const PERSON_SCHEMA = \"Person\";\r\n\r\n    export const PersonSchema = {\r\n    name: PERSON_SCHEMA,\r\n    primaryKey: 'id',\r\n    properties: {\r\n        id: 'int',\r\n        name: {type: 'string', indexed: true}\r\n    }\r\n    };\r\n    const databaseOptions = {\r\n    path: 'person.realm',\r\n    schema: [PersonSchema],\r\n    schemaVersion: 0\r\n    };\r\n\r\n    export const insertNewPerson = newPerson => new Promise((resolve, reject)=>{\r\n    Realm.open(databaseOptions).then(realm => {\r\n        realm.write(() => {\r\n            realm.create(PERSON_SCHEMA, newPerson);\r\n            resolve(newPerson);\r\n        });\r\n    }).catch((error) => reject(error));\r\n    });\r\n    export const queryAll = () => new Promise((resolve, reject) => {\r\n    Realm.open(databaseOptions).then(realm => {\r\n        let allPersons = realm.objects(PERSON_SCHEMA);\r\n        resolve(allPersons);\r\n    }).catch((error) => {\r\n        reject(error);\r\n    });\r\n    });\r\n    export default new Realm(databaseOptions);\r\n\r\n**APP.JS**\r\n\r\n    import React from 'react';\r\n    import {StyleSheet, Text, View} from 'react-native';\r\n    import {insertNewPerson, queryAll} from \"./databases/allSchemas\";\r\n     export default class App extends React.Component {\r\n      constructor(props) {\r\n        super(props);\r\n        this.state = {timePassed: false, value: '', realm: \"books\"};\r\n\r\n      }\r\n\r\n      render() {\r\n        const newPerson = {\r\n            id: Math.floor(Date.now() / 1000),\r\n            name: this.state.realm\r\n        };\r\n        insertNewPerson(newPerson).then().catch((error) => {\r\n            alert(error);\r\n        });\r\n        queryAll().then((value) => {\r\n            this.setState({value});\r\n        }).catch((error) => {\r\n        })\r\n        return (\r\n            <View>\r\n                <Text>\r\n                    {this.state.value}\r\n                </Text>\r\n            </View>\r\n        );\r\n    }\r\n    }"},"comment":{"url":"https://api.github.com/repos/realm/realm-js/issues/comments/407120394","html_url":"https://github.com/realm/realm-js/issues/1933#issuecomment-407120394","issue_url":"https://api.github.com/repos/realm/realm-js/issues/1933","id":407120394,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNzEyMDM5NA==","user":{"login":"nhachicha","id":1793238,"node_id":"MDQ6VXNlcjE3OTMyMzg=","avatar_url":"https://avatars0.githubusercontent.com/u/1793238?v=4","gravatar_id":"","url":"https://api.github.com/users/nhachicha","html_url":"https://github.com/nhachicha","followers_url":"https://api.github.com/users/nhachicha/followers","following_url":"https://api.github.com/users/nhachicha/following{/other_user}","gists_url":"https://api.github.com/users/nhachicha/gists{/gist_id}","starred_url":"https://api.github.com/users/nhachicha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhachicha/subscriptions","organizations_url":"https://api.github.com/users/nhachicha/orgs","repos_url":"https://api.github.com/users/nhachicha/repos","events_url":"https://api.github.com/users/nhachicha/events{/privacy}","received_events_url":"https://api.github.com/users/nhachicha/received_events","type":"User","site_admin":false},"created_at":"2018-07-23T16:33:48Z","updated_at":"2018-07-23T16:33:48Z","author_association":"CONTRIBUTOR","body":"I managed to run your code, however, you'll encounter a Realm error since you'll be inserting the same object (with the same primary key) everytime you render (since on query completion you call set state which calls `render` which will insert the object again , which obviously fails.)\r\n\r\n<img width=\"273\" alt=\"screen shot 2018-07-23 at 17 29 25\" src=\"https://user-images.githubusercontent.com/1793238/43090044-31e46234-8e9e-11e8-87da-1f0d74215a15.png\">\r\n\r\n\r\n<img width=\"872\" alt=\"screen shot 2018-07-23 at 17 31 45\" src=\"https://user-images.githubusercontent.com/1793238/43090084-50811a02-8e9e-11e8-8a69-89571c046ad4.png\">\r\n"}}
{"actor":{"display_login":"nhachicha"}}