react-native-reanimated-carousel: [4.0.0-alpha12] Metro error on Expo 51 / Web: Cannot access 'computedOffsetXValueWithAutoFillData' before initialization
Describe the bug
When starting up metro after migrating to Expo 51, carousel fails during initialization.
Screenshots
Metro error: Cannot access 'computedOffsetXValueWithAutoFillData' before initialization
5 | });
6 | exports.computedFillDataWithAutoFillData = computedFillDataWithAutoFillData;
> 7 | exports.computedOffsetXValueWithAutoFillData = computedOffsetXValueWithAutoFillData;
| ^
8 | exports.computedRealIndexWithAutoFillData = computedRealIndexWithAutoFillData;
9 | exports.convertToSharedIndex = convertToSharedIndex;
10 |
Call Stack
factory (node_modules/react-native-reanimated-carousel/lib/commonjs/utils/computed-with-auto-fill-data.js:7:48)
loadModuleImplementation (node_modules/metro-runtime/src/polyfills/require.js:273:5)
guardedLoadModule (node_modules/metro-runtime/src/polyfills/require.js:180:12)
require (node_modules/metro-runtime/src/polyfills/require.js:89:7)
factory (node_modules/react-native-reanimated-carousel/lib/commonjs/components/ItemRenderer.js:16:33)
loadModuleImplementation (node_modules/metro-runtime/src/polyfills/require.js:273:5)
guardedLoadModule (node_modules/metro-runtime/src/polyfills/require.js:180:12)
require (node_modules/metro-runtime/src/polyfills/require.js:89:7)
factory (node_modules/react-native-reanimated-carousel/lib/commonjs/components/Carousel.js:16:21)
loadModuleImplementation (node_modules/metro-runtime/src/polyfills/require.js:273:5)
Versions (please complete the following information):
- react: v18.2.0
- react-native: v0.74.1
- react-native-reanimated: v3.10.1
- react-native-reanimated-carousel: v4.0.0-alpha.12
- react-native-gesture-handler: v2.16.2
Additional context
Using metro to build web.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 17 (1 by maintainers)
Possible workaround: Add
"@babel/plugin-transform-block-scoping"to mybabel.config.jsplugins listGot this idea from this react-native-reanimated issue
I’d rather not need to add
"@babel/plugin-transform-block-scoping"to my plugin list just for this issue, but at least it seems to work 😃If you’re using react-native-reanimated-carousel in an Expo project, you can try the following method:
First, customize the metro configuration by running
npx expo customize metro.config.jsThen modify the code in the
metro.config.jsfile to the following:Hey there, @mortenmo! 👋 I’m here to help you with any bugs, questions, or contributions you have while you wait for a human maintainer. I’m a bot that can assist with all things related to the repository.
To resolve the initialization error “Cannot access ‘computedOffsetXValueWithAutoFillData’ before initialization” when starting up Metro after migrating to Expo 51, ensure that the function
computedOffsetXValueWithAutoFillDatais properly defined and exported before it is used. The provided code snippet already shows the correct definition and export of the function.Here is the relevant part of the code:
Ensure that this function is not being referenced before its definition in your code. If the error persists, it might be due to a circular dependency or an import issue. Double-check your import statements and the order of your function definitions to ensure there are no circular dependencies [1].
To continue talking to Dosu, mention @dosu.
+1
Having the same issue