Yusuf
Yusuf

Reputation: 87

React-Native Realm TypeError: Reflect.construct requires the first argument be a constructor - Error

I reinstalled the MacOs operating system, my working code has failed.

I don't understand, it was working before reinstalling.

My project detail is; "react": "16.9.0" "react-native": "0.61.1", "realm": "^3.6.5",

I was tried realm 3.2.0 and 3.1.0 versions but not working, the same error persists.

I'm getting this error ** My code is **

export function RealmDB_SetLoginUser(Data)
{
    realm.write(() =>
    {
        let LoginUser = realm.objects('LoginUser');

        realm.delete(LoginUser);

        realm.create('LoginUser', {
            Name: Data.Name,
            Password: Data.Password,
            IsTest: Data.IsTest,
        });
    });
}

Could you please help me?

Upvotes: 4

Views: 1596

Answers (1)

puran patidar
puran patidar

Reputation: 54

DataMo.schema = {
    name: 'DataMo',
    primaryKey: 'id',
    properties: {
        id: 'int',
        year: 'string',
    }
};
const realm: Realm = new Realm({
    schema: [
        DataMo.schema
    ]
});

export default realm;

Replace schema: [DataMo] to schema: [DataMo.schema]

Upvotes: 3

Related Questions