question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS] Cannot read property 'debugHosts' of undefined

See original GitHub issue

Hi There, i just did a vanilla installation for the realm specified here. However, i got this exception. I was not able to launch it at all. Its very similar to #527 and I read #392 for the fix but it doesnt work…

Steps Followed:

react-native init npm install --save realm rnpm link realm react-native run-ios

react-native: 0.41.2 ios: 10.0 osx 10.12.1 realm: 1.0.2

I have the below installation of the implementation. The library react-native-database is based on this repo.

/**
 * Created by hesk on 14/2/2017.
 */
import axios from 'axios';
import Database from 'react-native-database';
import S from 'react-native-storage';
import {AsyncStorage} from 'react-native';
import C from './constants';
import L from 'lodash';
const instance_ns = new S({
    size: 1000, storageBackend: AsyncStorage, enableCache: true, defaultExpires: 1000 * 3600 * 24,
});
const instance = axios.create({
    baseURL: C.DOMAIN,
    timeout: 60000,
    headers: {'X-Custom-Header': 'foobar'}
});
class User {
    add_user(user_id: string, _email: string, _firstName: string, _lastName: string) {
        database.write(() => {
            database.create('User', {id: user_id, email: _email, firstName: _firstName, lastName: _lastname})
        });
        settings.set(C.pref.USER_ID, user_id);
    }
}
User.schema = {
    name: 'User',
    primaryKey: 'id',
    properties: {
        id: 'string',
        username: {type: 'string', default: 'placeholderUsername'},
        lastLogin: {type: 'date', optional: true},
        firstName: {type: 'string', optional: true},
        lastName: {type: 'string', optional: true},
        email: {type: 'string', optional: true},
    },
};
class Basemap {

    resultFromSingleEntry(data) {
        if (L.isObject(data)) {
            database.write(() => {
                database.create('User', {
                        id: data.id,
                        fast_id: data.fast_id,
                        complete: data.complete,
                        owner: data.owner,
                        folder_base_name: data.folder_base_name,
                        secret_base_map_file: data.secret_base_map_file,
                        rename_file: data.rename_file,
                        mid_size: data.mid_size,
                        price: data.price,
                        baseprice: data.baseprice,
                        license_price: data.license_price,
                        factory_shared: data.factory_shared,
                        printed_shared: data.printed_shared,
                        print_limit: data.print_limit,
                        estprice: data.estprice,
                        currency: data.currency,
                        image_type: data.image_type,
                        createtime: data.createtime,
                        updatetime: new Date()
                    },
                )
            });
        }
    }
}
Basemap.schema = {
    name: 'Basemap',
    primaryKey: 'id',
    properties: {
        id: 'string',
        fast_id: 'string',
        complete: 'float',
        owner: 'string',
        folder_base_name: 'string',
        secret_base_map_file: 'string',
        rename_file: 'string',
        mid_size: 'string',
        price: 'int',
        baseprice: 'int',
        license_price: 'int',
        factory_shared: 'int',
        printed_shared: 'int',
        print_limit: 'int',
        estprice: 'int',
        currency: 'string',
        image_type: 'string',
        createtime: 'date',
        updatetime: 'date'
    }
};
class Setting {
    get ageSeconds() {
        return Math.floor((Date.now() - this.birthday.getTime()));
    }

    get age() {
        return ageSeconds() / 31557600000;
    }
}
Setting.schema = {
    name: 'Setting',
    primaryKey: 'key',
    properties: {
        key: 'string',
        value: 'string',
    },
};
const schema = {schema: [Basemap, Setting, User], schemaVersion: 1};
const database = new Database(schema);
const settings = new Settings(database);
let self;
export default class Axo {
    constructor(props) {
    }

    conf = {};

    static get getConfig() {
        return Axo.conf;
    }

    static _startApp(cb) {
        if (self == null) {
            self = new Axo();
        } else {
            self = this;
        }
        instance_ns
            .load({key: C.pref.INIT, autoSync: true, syncInBackground: true})
            .then(ret => {
                console.log("sync return", ret);
                self.conf = ret;
                cb();
            }).catch(err => {
            // any exception including data not found
            console.warn(err.message);
            switch (err.name) {
                case 'NotFoundError':
                    self._checkNetworkOnStart();
                    break;
                case 'ExpiredError':
                    self._checkNetworkOnStart();
                    break;
            }
        });

    }

    _checkNetworkOnStart() {
        let self = this;
        instance.get(C.uri_init).then(function (res) {
            if (res) {
                console.log("network successfully loaded", res);
                self.conf = ret;
                instance_ns.save({key: C.pref.INIT, rawData: res, expires: 1000 * 3600});
            }
        }).catch(err => {
            console.warn(err.message);
            switch (err.name) {
                case 'NotFoundError':

                    break;
                case 'ExpiredError':

                    break;
            }
        });
    }


}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:21 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jjheskcommented, Feb 16, 2017

realm is not usable… as of “realm”: “^1.0.2”

2reactions
fealebenpaecommented, Feb 15, 2017

Hey @jjhesk,

Try calling react-native link realm instead of rnpm link realm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'debugHosts' of undefined #1150 - GitHub
I have the problem "Cannot read property 'debugHosts' of undefined", I know this issue was closed but I believe it comes back again....
Read more >
react native - Cannot read property 'debugHosts' of undefined
Steps to fix: rnpm link realm. Add the module in the MainApplication.Java file, should look like this @Override protected List<ReactPackage> ...
Read more >
Cannot read property 'debugHosts' of undefined-React Native
Coding example for the question Cannot read property 'debugHosts' of undefined-React Native.
Read more >
Cannot read property 'debugHosts' of undefined -
I have the problem "Cannot read property 'debugHosts' of undefined", I know this issue was closed but I believe it comes back again....
Read more >
error cannot read property 'configurations' of undefined. react ...
I think the important part that I was missing even previously is to run pod install for iOS. For Android, the reason it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found