react-native-snap-carousel icon indicating copy to clipboard operation
react-native-snap-carousel copied to clipboard

ERROR TypeError: Cannot read property 'style' of undefined, js engine: hermes

Open yigitGoldtag opened this issue 1 month ago • 12 comments

After updating my Expo version and other packages, I get this error in Carousel.js;

I'm sure the error is here because when I remove it from the project, there is no problem. Even if it is installed in the project, it is not a problem, but when I run my code, it gives an error.

Here is my code; ` import React, { useState } from "react"; import { View, StyleSheet, Platform } from "react-native"; import Carousel, { Pagination } from "react-native-snap-carousel"; import Metrics from "../../styles/Dimensions";

const Slider = (props) => { const [activeSlide, setActiveSlide] = useState(0);

const [data, setData] = useState(props.slideDatas);

const _renderItem = ({ item, index }) => { return <View>{item.component}</View>; };

const pagination = () => { return ( <Pagination dotsLength={data.length} activeDotIndex={activeSlide} containerStyle={{ backgroundColor: "transparent", }} dotStyle={{ width: 10, height: 10, borderRadius: 5, backgroundColor: "#D6B87C", }} inactiveDotStyle={{ backgroundColor: "#D6B87C", }} inactiveDotOpacity={0.4} inactiveDotScale={0.6 * Metrics.horizontalScale} /> ); };

return ( <View style={styles.container}> <Carousel layout={props.assets ? "stack" : "default"} data={data} renderItem={_renderItem} sliderWidth={373 * Metrics.horizontalScale} itemWidth={327 * Metrics.horizontalScale} onSnapToItem={(index) => setActiveSlide(index)} /> <View style={{ }} > {pagination()} </View> </View> ); };

export default Slider;

`

Here is the error; ERROR TypeError: Cannot read property 'style' of undefined, js engine: hermes

WhatsApp Image 2024-05-15 at 15 54 16

yigitGoldtag avatar May 15 '24 12:05 yigitGoldtag

Although this is not a fundamental solution, I will write a method to resolve and execute the error. Since the error is thrown by the type

In “node_module/react-native-snap-carousel Delete all lines in “node_module/react-native-snap-carousel” that use “View.propTypes.style”. In the above example Remove all lines using “containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,” Delete all but one line of “View.propTypes.style”. Then you will get the next error, so repeat erasing the one line there. (View.propTypes.style this is the line that contains it)

You have to wait for the version to be updated.

Translated with DeepL.com (free version)

根本的な解決にはなりませんが、エラーを解消し実行する方法を書きます。 型でエラーを吐いているので

「node_module/react-native-snap-carousel」内の 「View.propTypes.style」を使用している行をすべて削除します。 上記の例では 「containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,」 の1行を全て消す。 そうすると次のエラーが出るので、そこの1行を消すことを繰り返します。(View.propTypes.styleこれが含まれている行です)

バージョンアップされるのを待つしかないです。

soshi1234 avatar May 15 '24 13:05 soshi1234

Although this is not a fundamental solution, I will write a method to resolve and execute the error. Since the error is thrown by the type

In “node_module/react-native-snap-carousel Delete all lines in “node_module/react-native-snap-carousel” that use “View.propTypes.style”. In the above example Remove all lines using “containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,” Delete all but one line of “View.propTypes.style”. Then you will get the next error, so repeat erasing the one line there. (View.propTypes.style this is the line that contains it)

You have to wait for the version to be updated.

Translated with DeepL.com (free version)

根本的な解決にはなりませんが、エラーを解消し実行する方法を書きます。 型でエラーを吐いているので

「node_module/react-native-snap-carousel」内の 「View.propTypes.style」を使用している行をすべて削除します。 上記の例では 「containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,」 の1行を全て消す。 そうすると次のエラーが出るので、そこの1行を消すことを繰り返します。(View.propTypes.styleこれが含まれている行です)

バージョンアップされるのを待つしかないです。

Unfortunately, this method did not work, it causes another error.

yigitGoldtag avatar May 16 '24 05:05 yigitGoldtag

1- Import ViewStyle from react-native. import { ViewStyle } from 'react-native';

2- Replace View.propTypes.style with ViewStyle in the (Carousel, Pagination, ParallaxImage, PaginationDot) files. 3- Ensure to patch the package after making the changes.

aguidad avatar May 16 '24 10:05 aguidad

1- Import ViewStyle from react-native. import { ViewStyle } from 'react-native';

2- Replace View.propTypes.style with ViewStyle in the (Carousel, Pagination, ParallaxImage, PaginationDot) files. 3- Ensure to patch the package after making the changes.

This solved my problem , thank you man!

yigitGoldtag avatar May 16 '24 12:05 yigitGoldtag

ViewStyle

how exactly does one patch a package?

quaddss52 avatar May 20 '24 14:05 quaddss52