-
-
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
Cannot access 'computeOffsetIfDataChanged' before initialization #729
Comments
Hey @AshishAcharya083! I'm here to help you with any bugs or questions you might have while waiting for a human maintainer. Let me know how I can assist you! I couldn't find a specific solution to the "Cannot access 'computeOffsetIfDataChanged' before initialization" error in the repository. However, this type of error in JavaScript or React Native typically occurs when you try to use a variable or function before it has been declared or initialized. Here are some general steps you can take to troubleshoot and potentially resolve this issue:
If these steps do not resolve the issue, you might want to look into similar issues that have been reported. For instance, there is an open issue where a similar problem was noted, and it was suggested that the problem might not occur when the debugger is not in use [2]. Additionally, checking the configuration of |
I am using v4.0.0-canary.22 and this is happening to me as well, but only in a web browser. The same code runs fine on a physical iOS device. My code is very simple, using expo navigation template with the carousel example from the usage section. |
I'm getting ths issue as well on my iPhone |
any updates? |
Its some kind of build issue where in the compiled files the exports are above the definitions causing errors. |
Seeing the same here with expo 52, react-native 0.76.5 (basically the latest as of a week ago) Tested with 4.0.0-canary.22, 21, 20, and alpha.10, the offending function changed at some point in that sequence. Any thoughts on how to resolve? |
it seems that everything is due to 4.0.0.0-canary.22, we have to wait for them to resolve it to be able to test on the web. |
There is a way to temporarily fix this bug. run the file "scripts/fix-reanimated-carousel.js" with this code:
|
@TheForgetTime thanks. I'll give this a try later. I also noticed this fixes the issue as well. Adding this to the metro.config.js
|
Using @TheForgetTime's script from above, I created a patch with patch-package. "patches/react-native-reanimated-carousel+4.0.0-canary.22.patch": diff --git a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/compute-offset-if-data-changed.js b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/compute-offset-if-data-changed.js
index 6741689..7fb4c04 100644
--- a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/compute-offset-if-data-changed.js
+++ b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/compute-offset-if-data-changed.js
@@ -3,8 +3,6 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
-exports.computeOffsetIfDataChanged = computeOffsetIfDataChanged;
-exports.omitZero = omitZero;
function omitZero(a, b) {
"worklet";
@@ -50,3 +48,5 @@ function computeOffsetIfDataChanged(params) {
return handlerOffset;
}
//# sourceMappingURL=compute-offset-if-data-changed.js.map
+exports.computeOffsetIfDataChanged = computeOffsetIfDataChanged;
+exports.omitZero = omitZero;
\ No newline at end of file
diff --git a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/compute-offset-if-size-changed.js b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/compute-offset-if-size-changed.js
index 42a4eca..c589f64 100644
--- a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/compute-offset-if-size-changed.js
+++ b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/compute-offset-if-size-changed.js
@@ -3,7 +3,6 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
-exports.computeOffsetIfSizeChanged = computeOffsetIfSizeChanged;
function computeOffsetIfSizeChanged(params) {
"worklet";
@@ -16,3 +15,4 @@ function computeOffsetIfSizeChanged(params) {
return handlerOffset / prevSize * size;
}
//# sourceMappingURL=compute-offset-if-size-changed.js.map
+exports.computeOffsetIfSizeChanged = computeOffsetIfSizeChanged;
\ No newline at end of file
diff --git a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/computed-with-auto-fill-data.js b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/computed-with-auto-fill-data.js
index 0d84fba..174ef4d 100644
--- a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/computed-with-auto-fill-data.js
+++ b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/computed-with-auto-fill-data.js
@@ -3,10 +3,6 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
-exports.computedFillDataWithAutoFillData = computedFillDataWithAutoFillData;
-exports.computedOffsetXValueWithAutoFillData = computedOffsetXValueWithAutoFillData;
-exports.computedRealIndexWithAutoFillData = computedRealIndexWithAutoFillData;
-exports.convertToSharedIndex = convertToSharedIndex;
var _constants = require("../constants");
@@ -122,3 +118,7 @@ function computedFillDataWithAutoFillData(params) {
return data;
}
//# sourceMappingURL=computed-with-auto-fill-data.js.map
+exports.computedFillDataWithAutoFillData = computedFillDataWithAutoFillData;
+exports.computedOffsetXValueWithAutoFillData = computedOffsetXValueWithAutoFillData;
+exports.computedRealIndexWithAutoFillData = computedRealIndexWithAutoFillData;
+exports.convertToSharedIndex = convertToSharedIndex;
\ No newline at end of file
diff --git a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/deal-with-animation.js b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/deal-with-animation.js
index 2851db7..8050ada 100644
--- a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/deal-with-animation.js
+++ b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/deal-with-animation.js
@@ -3,7 +3,6 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
-exports.dealWithAnimation = dealWithAnimation;
var _reactNativeReanimated = require("react-native-reanimated");
@@ -19,3 +18,4 @@ function dealWithAnimation(withAnimation) {
}
}
//# sourceMappingURL=deal-with-animation.js.map
+exports.dealWithAnimation = dealWithAnimation;
\ No newline at end of file
diff --git a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/handleroffset-direction.js b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/handleroffset-direction.js
index e72e598..7d681a6 100644
--- a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/handleroffset-direction.js
+++ b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/handleroffset-direction.js
@@ -3,7 +3,6 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
-exports.handlerOffsetDirection = handlerOffsetDirection;
function handlerOffsetDirection(handlerOffset, fixedDirection) {
"worklet";
@@ -14,3 +13,4 @@ function handlerOffsetDirection(handlerOffset, fixedDirection) {
return Math.sign(handlerOffset.value);
}
//# sourceMappingURL=handleroffset-direction.js.map
+exports.handlerOffsetDirection = handlerOffsetDirection;
\ No newline at end of file
diff --git a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/log.js b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/log.js
index dc52a04..f908c38 100644
--- a/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/log.js
+++ b/node_modules/react-native-reanimated-carousel/lib/commonjs/utils/log.js
@@ -3,8 +3,6 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
-exports.log = log;
-exports.round = round;
/**
* In worklet
@@ -20,3 +18,5 @@ function round(number) {
return Math.round(number);
}
//# sourceMappingURL=log.js.map
+exports.log = log;
+exports.round = round;
\ No newline at end of file
|
`import { Text, View, StyleSheet, FlatList, Dimensions } from 'react-native';
import { dummyHomePageTopCard } from '../../data/dummyData';
import Carousel from 'react-native-reanimated-carousel';
import ActionButtonCard, {
ActionButtonCardsProps
} from '../cards/ActionButtonCard';
export function ActionButtonCardsList() {
const width = Dimensions.get('window').width;
return (
<View style={{ flex: 1 }}>
<Carousel
loop
width={200}
height={300}
// autoPlay={true}
data={dummyHomePageTopCard}
scrollAnimationDuration={1000}
onSnapToItem={(index) => console.log('current index:', index)}
renderItem={({ item }) => {
return (
);
}}
/>
);
}
export default ActionButtonCardsList;
const styles = StyleSheet.create({
listStyle: {
width: '100%',
marginTop: 30
}
});
`
Describe the bug
A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks!
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Versions (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: