Today I faced an issue, where I had an array in a schema. After reading the record from realm database, I was converting that record to a JSON manually (We should generally use the toJSON method provided realmJS). I had copied all the values into a new object but assigned an array as it is to the new object. Well there started all the problems, as that array is still referring the original realm object and whenever I tried to clone the new object, I was getting following error:
[Error: Exception in HostFunction: no internal field
Error: no internal field
at get_type (native)
at method (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:146404:24)
at from (native)
at _iterableToArray (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:2267:120)
at _toConsumableArray (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:2238:53)
at value (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:146394:46)
at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:158763:43)
at filter (native)
at ?anon_0_ (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:158762:52)
at next (native)
at asyncGeneratorStep (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:24822:26)
at _next (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:24844:29)
at tryCallOne (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:53:16)
at anonymous (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:139:27)
at apply (native)
at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:31482:26)
at _callTimer (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:31382:17)
at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:31417:17)
at callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:31624:44)
at __callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:23778:46)
at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:23557:45)
at __guard (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:23761:15)
at flushedQueue (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:23556:21)
at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.bundle.exampleApp.dev:23549:33)]
So, anybody facing that issue, simply de-structure the array which you are getting from realm object to create new array and then assign to the new object. Your issue will be solved.
Cheers and Peace Out!!!