mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-10 14:25:58 +00:00
Update index.js to report missing react-native link
This commit is contained in:
parent
33c2f7cefc
commit
1073a4bbc0
17
lib/index.js
17
lib/index.js
@ -23,7 +23,6 @@ function nodeRequire(module) {
|
||||
return require(module);
|
||||
}
|
||||
|
||||
|
||||
function getContext() {
|
||||
// If process is an object, we're probably running in Node or Electron
|
||||
// From: http://stackoverflow.com/a/24279593/1417293
|
||||
@ -36,14 +35,16 @@ function getContext() {
|
||||
return 'nodejs';
|
||||
}
|
||||
|
||||
// If we've already injected the Realm class, we are probably
|
||||
// running in a jscore environment, either directly or via React Native
|
||||
if (typeof Realm !== 'undefined') {
|
||||
if (typeof navigator !== 'undefined' &&
|
||||
navigator.product === 'ReactNative') { // eslint-disable-line no-undef
|
||||
return 'reactnative';
|
||||
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { // eslint-disable-line no-undef
|
||||
if (typeof Realm === 'undefined'){
|
||||
throw new Error('Missing Realm constructor. Did you run "react-native link realm"? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting');
|
||||
}
|
||||
return 'reactnative';
|
||||
}
|
||||
|
||||
// If we're not running in React Native but we already injected the Realm class,
|
||||
// we are probably running in a pure jscore environment
|
||||
if (typeof Realm !== 'undefined') {
|
||||
return 'jscore';
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ switch(getContext()) {
|
||||
}
|
||||
|
||||
if (!realmConstructor) {
|
||||
throw new Error('Missing Realm constructor. Did you run "react-native link realm"? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting');
|
||||
throw Error("Error trying to establish execution context");
|
||||
}
|
||||
|
||||
require('./extensions')(realmConstructor);
|
||||
|
Loading…
x
Reference in New Issue
Block a user