Adds a new API to NitroModules: NitroModules.hasNativeState(value).
With this API, we guard the toString() call of a HybridObject in release builds because we relied on an error being thrown, which turns into an assert (crash) in release.
To avoid relying on an error being thrown, we instead now somewhat safely check if we can stringify an object by checking if it has toString() or inherits from it - and then we check if it has NativeState. It is a fair assumption that toString() from prototype only works if we have NativeState, at least in the Nitro world.
Adds a new API to
NitroModules
:NitroModules.hasNativeState(value)
.With this API, we guard the
toString()
call of a HybridObject in release builds because we relied on an error being thrown, which turns into an assert (crash) in release. To avoid relying on an error being thrown, we instead now somewhat safely check if we can stringify an object by checking if it hastoString()
or inherits from it - and then we check if it has NativeState. It is a fair assumption thattoString()
from prototype only works if we have NativeState, at least in the Nitro world.