Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 70fea4d

Browse files
authored
Remove warning when calling measure from RN runtime (software-mansion#4526)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## 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 <!-- Provide a minimal but complete code snippet that can be used to test out this change along with instructions how to run it and a description of the expected behavior. -->
1 parent 3c14702 commit 70fea4d

1 file changed

Lines changed: 0 additions & 8 deletions

File tree

src/reanimated2/NativeMethods.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ if (isWeb()) {
3939
measure = (animatedRef: RefObjectFunction<Component>) => {
4040
'worklet';
4141
if (!_WORKLET) {
42-
console.warn(
43-
'[Reanimated] measure() was called from the main JS context. Measure is ' +
44-
'only available in the UI runtime. This may also happen if measure() ' +
45-
'was called by a worklet in the useAnimatedStyle hook, because useAnimatedStyle ' +
46-
'calls the given worklet on the JS runtime during render. If you want to ' +
47-
'prevent this warning then wrap the call with `if (_WORKLET)`. Then it will ' +
48-
'only be called on the UI runtime after the render has been completed.'
49-
);
5042
return null;
5143
}
5244

0 commit comments

Comments
 (0)