-
-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.0.0-alpha12] Metro error on Expo 51 / Web: Cannot access 'computedOffsetXValueWithAutoFillData' before initialization #634
Comments
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 Here is the relevant part of the code: export function computedOffsetXValueWithAutoFillData(
params: BaseParams<{
rawDataLength: number
value: number
size: number
}>,
) {
"worklet";
const { rawDataLength, value, size, loop, autoFillData } = params;
if (isAutoFillData({ loop, autoFillData })) {
switch (rawDataLength) {
case SINGLE_ITEM:
return value % size;
case DOUBLE_ITEM:
return value % (size * 2);
}
}
return value;
} 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]. |
same |
Having the same issue |
+1 |
I wonder if this is related to Babel's config? The React Native Reanimated docs requires I'm using Expo and getting the same |
Possible workaround: Add Got this idea from this react-native-reanimated issue I'd rather not need to add |
This solution does not seem to work for me. I am using a Windows and using the Web version for testing. |
I found the solution. As mentioned earlier, this issue is because of a circular dependency in The solution is to simply upgrade the
|
This doesn't seem to work for me, even after updating to react-native-gesture-handler 2.18.1. I also tried 2.19.0, still no luck. |
Same here, tested 2.20.0 and no luck either |
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 Then modify the code in the /* eslint-env node */
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');
const path = require('path');
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
config.resolver.resolveRequest = (context, realModuleName, platform) => {
if (realModuleName === 'react-native-reanimated-carousel') {
return {
filePath: path.resolve(__dirname, 'node_modules/react-native-reanimated-carousel/lib/module/index.js'),
type: 'sourceFile',
};
}
return context.resolveRequest(context, realModuleName, platform);
};
module.exports = config; |
Thanks @ystrdy ! I can confirm that doing this fixes the problem. I was previously using @resticker 's solution. With @ystrdy 's solution I was able to remove the babel plugin and its working fine. This solution should be added to the docs IMO, specially considering Expo is being recommended by default by RN now. |
same here. |
Thank you @ystrdy ! Your solution worked for me! |
Just to organise the multiple issues going on here: 1
In my case, this fixed the following warning:
2
In my case, this fixed the following static rendering error:
Are us metro users stuck with this approach forever? It's a circular dependency issue. Is there a cleaner fix? 3 (bonus)This issue recommends jumping onto version 4 (not yet stable release) - although for me not completely necessary. PS. wen v4 release?! |
Describe the bug
When starting up metro after migrating to Expo 51, carousel fails during initialization.
Screenshots
Versions (please complete the following information):
Additional context
Using metro to build web.
The text was updated successfully, but these errors were encountered: