Skip to content
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

TypeError: Cannot read properties of undefined (reading 'toString') #301

Closed
jonnypage opened this issue Nov 2, 2022 · 11 comments
Closed
Assignees
Labels
bug Something isn't working needs review The issue has been solved, Wait for confirmation.

Comments

@jonnypage
Copy link

Trying the default example from the readme:

<View style={{ flex: 1 }}>
            <Carousel
                loop
                width={width}
                height={width / 2}
                autoPlay={true}
                data={[...new Array(6).keys()]}
                scrollAnimationDuration={1000}
                onSnapToItem={(index) => console.log('current index:', index)}
                renderItem={({ index }) => (
                    <View
                        style={{
                            flex: 1,
                            borderWidth: 1,
                            justifyContent: 'center',
                        }}
                    >
                        <Text style={{ textAlign: 'center', fontSize: 30 }}>
                            {index}
                        </Text>
                    </View>
                )}
            />
        </View>

is erroring out with:

TypeError: Cannot read properties of undefined (reading 'toString')
This error is located at:
    in IScrollViewGesture (at Carousel.tsx:200)

Using:
"react-native-gesture-handler": "^2.4.2",
"react-native-reanimated": "^2.8.0"
"react-native-reanimated-carousel": "^3.1.3",
"react-native": "0.68.1"

@jonnypage jonnypage added the bug Something isn't working label Nov 2, 2022
@jonnypage
Copy link
Author

Simulator Screen Shot - iPhone 13 - 2022-11-02 at 16 42 59

@1974892005
Copy link

I also encountered this problem

@dohooo dohooo closed this as completed in 7a82994 Nov 4, 2022
@dohooo
Copy link
Owner

dohooo commented Nov 4, 2022

3.1.5

@dohooo dohooo added the needs review The issue has been solved, Wait for confirmation. label Nov 4, 2022
@asgu
Copy link

asgu commented Nov 5, 2022

problem still exists on 3.1.5 when trying the default example, and tried to copy code from mentioned commit - also doesnt work

"react-native-gesture-handler": "^2.8.0",
"react-native-reanimated": "^2.12.0",
"react-native-reanimated-carousel": "^3.1.5",

@dohooo
Copy link
Owner

dohooo commented Nov 5, 2022

problem still exists on 3.1.5 when trying the default example, and tried to copy code from mentioned commit - also doesnt work

"react-native-gesture-handler": "^2.8.0", "react-native-reanimated": "^2.12.0", "react-native-reanimated-carousel": "^3.1.5",

It doesn't seem to have any relation with this library. Please check whether the config is correct.

@jonnypage
Copy link
Author

jonnypage commented Nov 10, 2022

The problem still exists, seeing the same error using 3.1.5 using the exact code above

  • cleared node_modules and reinstalled with 3.1.5 in package

"react-native-gesture-handler": "^2.4.2",
"react-native-reanimated": "^2.8.0"
"react-native-reanimated-carousel": "^3.1.5",
"react-native": "0.68.1"

@dohooo
Copy link
Owner

dohooo commented Nov 11, 2022

The problem still exists, seeing the same error using 3.1.5 using the exact code above

  • cleared node_modules and reinstalled with 3.1.5 in package

"react-native-gesture-handler": "^2.4.2", "react-native-reanimated": "^2.8.0" "react-native-reanimated-carousel": "^3.1.5", "react-native": "0.68.1"

Could you provide a repository that can reproducing this problem? It seems this problem has a few people encountered. So I can fix it quickly if you provide more information to me.

@gzh1612
Copy link

gzh1612 commented Nov 16, 2022

The problem still exists, seeing the same error using 3.1.5 using the exact code above

  • cleared node_modules and reinstalled with 3.1.5 in package

"react-native-gesture-handler": "^2.4.2", "react-native-reanimated": "^2.8.0" "react-native-reanimated-carousel": "^3.1.5", "react-native": "0.68.1"

I also had this problem when using
Please refer to the documentation to configure react-native-reanimated
https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation
module.exports = {
presets: [
...
],
plugins: [
...
'react-native-reanimated/plugin',
],
};

@ugurcanalyuz
Copy link

Solution for me.

babel.config.js
plugins: ['react-native-reanimated/plugin']

and "expo start -c"

@JevonJ
Copy link

JevonJ commented Jan 28, 2023

What worked for me:

module.exports = {
presets: [
...
],
plugins: [
...
'react-native-reanimated/plugin',
],
};

and then

yarn start --reset-cache

@leozhang007
Copy link

When I add plugins, I get the following error
截屏2023-12-13 11 55 18

using:
"react-native-gesture-handler": "^2.14.0",
"react-native-reanimated": "^3.6.1",
"react-native-reanimated-carousel": "^3.5.1",

demo:
import {Dimensions, Text, View} from 'react-native'
import Carousel from 'react-native-reanimated-carousel'

function App() {
const width = Dimensions.get('window').width
return (
<View style={{flex: 1}}>
<Carousel
loop
width={width}
height={width / 2}
autoPlay={true}
data={[...new Array(6).keys()]}
scrollAnimationDuration={1000}
onSnapToItem={index => console.log('current index:', index)}
renderItem={({index}) => (
<View
style={{
flex: 1,
borderWidth: 1,
justifyContent: 'center',
}}
>
<Text style={{textAlign: 'center', fontSize: 30}}>{index}

)}
/>

)
}

export default App

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs review The issue has been solved, Wait for confirmation.
Projects
None yet
Development

No branches or pull requests

8 participants