software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.6k stars 1.26k forks source link

Warnings in console while running web expo #5967

Open djaffer opened 2 months ago

djaffer commented 2 months ago

Description

There are 31 warnings showing for react-native-reanimated/lib/module/index.web.js file not exported correctly. This issue has been consistently overlooked. The exporting is not done properly with react-native-reanimated/lib/module/index.web.js.

 WARNING in ./node_modules/@react-navigation/drawer/lib/module/views/legacy/Overlay.js:26
export 'default'.'interpolateNode' (imported as 'Animated') was not found in 'react-native-reanimated' (possible exports: FlatList, Image, ScrollView, Text, View, addWhitelistedNativeProps, addWhitelistedUIProps, createAnimatedComponent)
  24 | import Animated from 'react-native-reanimated';
  25 | var interpolateDeprecated = Animated.interpolate,
> 26 |   interpolateNode = Animated.interpolateNode,
  27 |   cond = Animated.cond,
  28 |   greaterThan = Animated.greaterThan;
  29 | var interpolate = interpolateNode != null ? interpolateNode : interpolateDeprecated;

WARNING in ./node_modules/@react-navigation/drawer/lib/module/views/legacy/Overlay.js:27
export 'default'.'cond' (imported as 'Animated') was not found in 'react-native-reanimated' (possible exports: FlatList, Image, ScrollView, Text, View, addWhitelistedNativeProps, addWhitelistedUIProps, createAnimatedComponent)
  25 | var interpolateDeprecated = Animated.interpolate,
  26 |   interpolateNode = Animated.interpolateNode,
> 27 |   cond = Animated.cond,
  28 |   greaterThan = Animated.greaterThan;
  29 | var interpolate = interpolateNode != null ? interpolateNode : interpolateDeprecated;
  30 | var PROGRESS_EPSILON = 0.05;

WARNING in ./node_modules/@react-navigation/drawer/lib/module/views/legacy/Overlay.js:28
export 'default'.'greaterThan' (imported as 'Animated') was not found in 'react-native-reanimated' (possible exports: FlatList, Image, ScrollView, Text, View, addWhitelistedNativeProps, addWhitelistedUIProps, createAnimatedComponent)
  26 |   interpolateNode = Animated.interpolateNode,
  27 |   cond = Animated.cond,
> 28 |   greaterThan = Animated.greaterThan;
  29 | var interpolate = interpolateNode != null ? interpolateNode : interpolateDeprecated;
  30 | var PROGRESS_EPSILON = 0.05;
  31 | var Overlay = React.forwardRef(function Overlay(_ref, ref) {

web compiled with 33 warnings

Here is patch that fixes it:

diff --git a/node_modules/react-native-reanimated/lib/module/index.web.js b/node_modules/react-native-reanimated/lib/module/index.web.js
index bba2514..2d6671c 100644
--- a/node_modules/react-native-reanimated/lib/module/index.web.js
+++ b/node_modules/react-native-reanimated/lib/module/index.web.js
@@ -1,5 +1,8 @@
 'use strict';

 export * from './reanimated2';
-export * as default from './Animated'; // If this line fails, you probably forgot some installation steps. Check out the installation guide here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started#installation 1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) 2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache
+// export * as default from './Animated'; // If this line fails, you probably forgot some installation steps. Check out the installation guide here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started#installation 1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) 2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache
+import * as _default from './Animated';
+export default _default;
 //# sourceMappingURL=index.web.js.map
+

Steps to reproduce

Install fresh 3.10.0 then run expo web.

Snack or a link to a repository

https://snack.expo.io/

Reanimated version

3.10.0

React Native version

0.72.8

Platforms

Web

JavaScript runtime

Hermes

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 2 months ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

tomekzaw commented 1 month ago

@djaffer Thanks for reporting this issue as well as submitting a patch.

I'm afraid we can't really replace export * as default from './Animated'; with separate import and export as it breaks tree-shaking.

Also, Reanimated 3 no longer exports interpolateNode, cond, greaterThan etc.

It looks like you might be using an outdated version of @react-navigation/drawer, can you please upgrade to the latest and see it if helps?

djaffer commented 1 month ago

Does it require upgrading to expo 50? I am using "@react-navigation/drawer": "^6.6.15",