From 70fea4d08340631de6fa0898c9b0aeb19617f794 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Mon, 5 Jun 2023 15:54:29 +0200 Subject: [PATCH] Remove warning when calling `measure` from RN runtime (#4526) ## Summary This PR removes a warning that would trigger when `measure` function was called from the main RN runtime. The main motivation behind adding this `console.warn` was to force the developer to explicitly cover the case when `measure` is called from the RN runtime using `if (!_WORKLET) { ... }` guard, which, let's be honest, is quite uncomfortable. On the other hand, when measurement cannot be made, e.g. when called from the UI runtime but when the view is not mounted yet, `measure` returns `null`, which needs to be handled with `if (measured === null) { ... }`. It makes sense to merge these two cases since they can be handled identically. ## Test plan --- src/reanimated2/NativeMethods.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/reanimated2/NativeMethods.ts b/src/reanimated2/NativeMethods.ts index e7d40142016..0663d2d7338 100644 --- a/src/reanimated2/NativeMethods.ts +++ b/src/reanimated2/NativeMethods.ts @@ -39,14 +39,6 @@ if (isWeb()) { measure = (animatedRef: RefObjectFunction) => { 'worklet'; if (!_WORKLET) { - console.warn( - '[Reanimated] measure() was called from the main JS context. Measure is ' + - 'only available in the UI runtime. This may also happen if measure() ' + - 'was called by a worklet in the useAnimatedStyle hook, because useAnimatedStyle ' + - 'calls the given worklet on the JS runtime during render. If you want to ' + - 'prevent this warning then wrap the call with `if (_WORKLET)`. Then it will ' + - 'only be called on the UI runtime after the render has been completed.' - ); return null; }