meliorence / react-native-snap-carousel

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.
BSD 3-Clause "New" or "Revised" License
10.22k stars 2.25k forks source link

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

Open yigitGoldtag opened 2 weeks ago

yigitGoldtag commented 2 weeks ago

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 {item.component}; };

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 (

setActiveSlide(index)} /> {pagination()}
</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

soshi1234 commented 2 weeks ago

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これが含まれている行です)

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

yigitGoldtag commented 2 weeks ago

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.

aguidad commented 2 weeks ago

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.

yigitGoldtag commented 2 weeks ago

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!

quaddss52 commented 1 week ago

ViewStyle

how exactly does one patch a package?

AbdulBasit-Kagzi commented 1 week ago

I am facing the same issue

aguidad commented 1 week ago

ViewStyle

how exactly does one patch a package?

look at the doc patch-package

mkalavishvili99 commented 1 week ago

I am facing the same issue

already fix this problem ? if you fix please help me

nomilogic commented 1 week ago

react-native-snap-carousel+3.9.1.patch Patch fix for the above issue

quaddss52 commented 1 week ago

ViewStyle

how exactly does one patch a package?

look at the doc patch-package

thanks, my issue is resolved