Realm-js: EXPO Missing realm constructor did you run react-native link realm??

Created on 30 Jul 2017  路  8Comments  路  Source: realm/realm-js

Goals

I want to start using realm with react native (all platforms, incl. windows). So I followed your install instructions and copied few bits of code. I am also using expo, the new react-native way to run applications. The problem is I receive an error. I already done linking, both with rnpm and with react-native - didn't solve my problem.
Probably after ejecting it will work but I dont have mac to test my iOS part so I need to stay with expo.
Problem may be that expo is missing something.

Expected Results

I expected Realm to start normally.

Actual Results

image

Steps to Reproduce

Create RN app with create-react-native-app, open emulator and run npm android OR connect phone with installed expo to the same network as your PC and run npm start on PC.

Code Sample

import Realm from 'realm';

const CarSchema = {
  name: 'Car',
  properties: {
    make:  'string',
    model: 'string',
    miles: {type: 'int', default: 0},
  }
};
const PersonSchema = {
  name: 'Person',
  properties: {
    name:     'string',
    birthday: 'date',
    cars:     {type: 'list', objectType: 'Car'},
    picture:  {type: 'data', optional: true}, // optional property
  }
};

// Initialize a Realm with Car and Person models
let realm = new Realm({schema: [CarSchema, PersonSchema]});

realm.write(() => {
  let car = realm.create('Car', {
    make: 'Honda',
    model: 'Civic',
    miles: 750,
  });

  // you can access and set all properties defined in your model
  console.log('Car type is ' + car.make + ' ' + car.model);
  car.miles = 1500;
});

Version of Realm and Tooling

"dependencies": {
    "expo": "^19.0.0",
    "react": "^16.0.0-alpha.12",
    "react-native": "^0.46.1",
    "react-redux": "^5.0.5",
    "realm": "^1.10.0",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0"
  }
  • Client OS & Version:

    • Win10 Pro 64bit

    • WebStorm 2017.1.4

    • Android Emulator with Nexus_API_23

  • None

Most helpful comment

Reeeeeeeeeeeeeeeeeeeeeeeeeeeealm pls!

All 8 comments

Expo doesn't support Realm yet (https://forums.expo.io/t/is-realm-support-for-expo-coming/31) which explains it. Please ask Expo to add support.

The problem is still unsolved

Reeeeeeeeeeeeeeeeeeeeeeeeeeeealm pls!

@ali-so Doesn't help much here :-) Express the need here: https://expo.canny.io/feature-requests/p/support-for-realm

@kneth i am using expo but i have detached my project from expo . Seperate ios/android folders have been created .I assume then realm should work as normal ??

@kaulsalil88 I haven't tried that. Please report any findings :-)

Works properly on Android ,on IOS it just freezes the application doesnt throw any error . I am also not able to debug the issue further js debugging in the version of realm that i am using is causing the app to crash .

@kaulsalil88 At the moment, Realm isn't supported by Expo. It would be unusual if it works on Android.

P/s: I've added an upvote to Expo's Feature Request for Realm, here is a link if anyone interested. https://expo.canny.io/feature-requests
(search form 'Realm')

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ugendrang picture ugendrang  路  3Comments

CrystalRanita picture CrystalRanita  路  3Comments

kontinuity picture kontinuity  路  3Comments

fever324 picture fever324  路  4Comments

MihaelIsaev picture MihaelIsaev  路  3Comments