Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions android/src/main/cpp/NativeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ void NativeProxy::setGlobalProperties(
jsRuntime.global().setProperty(
jsRuntime, "_WORKLET_RUNTIME", workletRuntimeValue);

jsRuntime.global().setProperty(jsRuntime, "_WORKLET", false);

#ifdef RCT_NEW_ARCH_ENABLED
jsRuntime.global().setProperty(jsRuntime, "_IS_FABRIC", true);
#else
Expand Down
2 changes: 2 additions & 0 deletions ios/REAModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ - (void)setBridge:(RCTBridge *)bridge

runtime.global().setProperty(runtime, "_WORKLET_RUNTIME", workletRuntimeValue);

runtime.global().setProperty(runtime, "_WORKLET", false);

runtime.global().setProperty(runtime, "_IS_FABRIC", true);

auto version = getReanimatedVersionString(runtime);
Expand Down
2 changes: 2 additions & 0 deletions ios/native/REAInitializer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ - (void)setBridge:(RCTBridge *)bridge;

runtime.global().setProperty(runtime, "_WORKLET_RUNTIME", workletRuntimeValue);

runtime.global().setProperty(runtime, "_WORKLET", false);

runtime.global().setProperty(runtime, "_IS_FABRIC", false);

auto version = getReanimatedVersionString(runtime);
Expand Down
13 changes: 7 additions & 6 deletions src/reanimated2/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function runOnUIImmediately<A extends any[], R>(
worklet: ComplexWorkletFunction<A, R>
): (...args: A) => void {
'worklet';
if (__DEV__ && !IS_JEST && _WORKLET) {
if (__DEV__ && !IS_WEB && _WORKLET) {
throw new Error(
'runOnUIImmediately() cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.'
);
Expand All @@ -141,11 +141,12 @@ export function runOnUIImmediately<A extends any[], R>(
};
}

if (__DEV__) {
try {
// eslint-disable-next-line @typescript-eslint/no-empty-function
runOnUI(() => {});
} catch (e) {
if (__DEV__ && !IS_WEB) {
const f = () => {
'worklet';
};
// @ts-ignore plugin
if (f.__workletHash === undefined) {
throw new Error(
'Failed to create a worklet. Did you forget to add Reanimated Babel plugin in babel.config.js? See installation docs at https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation#babel-plugin.'
);
Expand Down