diff --git a/CHANGELOG.md b/CHANGELOG.md index e8240d05a9..93dddaaf6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,7 @@ x.x.x Release notes (yyyy-MM-dd) * Catching missing libjsi.so when loading the librealm.so and rethrowing a more meaningful error, instructing users to upgrade their version of React Native. ### Fixed -* ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?) -* None. +* Fixed support of user defined classes that don't extend `Realm.Object`. ### Compatibility * MongoDB Realm Cloud. diff --git a/src/jsi/jsi_class.hpp b/src/jsi/jsi_class.hpp index dab474dfe0..615cfbcc1b 100644 --- a/src/jsi/jsi_class.hpp +++ b/src/jsi/jsi_class.hpp @@ -128,7 +128,7 @@ inline void copyProperty(JsiEnv env, const fbjsi::Object& from, const fbjsi::Obj { auto prop = ObjectGetOwnPropertyDescriptor(env, from, name); REALM_ASSERT_RELEASE(prop); - defineProperty(env, to, "name", *prop); + defineProperty(env, to, name, *prop); } inline constexpr const char g_internal_field[] = "__Realm_internal"; @@ -439,9 +439,10 @@ class ObjectWrap { return nullptr; throw fbjsi::JSError(env, "no internal field"); } - if (!JsiObj(object)->instanceOf(env, *s_ctor)) { - throw fbjsi::JSError(env, "calling method on wrong type of object"); - } + // The following check is disabled to support user defined classes that doesn't extend Realm.Object + // if (!JsiObj(object)->instanceOf(env, *s_ctor)) { + // throw fbjsi::JSError(env, "calling method on wrong type of object"); + // } return unwrapUnique(env, std::move(internal)); } static void set_internal(JsiEnv env, const JsiObj& object, Internal* data)