fix: fix error in bridgeless due to nativeCallSyncHook #778
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Closes #779
Apps running on bridgless, old arch always has
nativeCallSyncHook
as undefined making this:react-native-mmkv/src/createMMKV.ts
Lines 49 to 53 in 6682adf
always throw.
Check this guide on insuring the interop layer:
[JavaScript]
global.nativeCallSyncHook
can't be used to detect legacy "Remote Debugging in Chrome" with JSCglobal.nativeCallSyncHook === 'undefined'
is a common way to check if you're running in "Remote Debugging in Chrome" (which is not supported with Hermes, only JSC). This is often used to provide some fallback behavior for sync native functions, because they do not work in the legacy remote debugging environment. Use"RN$Bridgeless" in global && RN$Bridgeless === true
to determine if you are running in bridgeless. Learn more in LinusU/react-native-get-random-values#57.It is generally not recommended to fork behavior based on whether bridgeless is enabled — this is an escape hatch that should be used sparingly.
Example "isRemoteDebuggingInChrome()" function