react-native-snap-carousel
react-native-snap-carousel copied to clipboard
ERROR TypeError: Cannot read property 'style' of undefined, js engine: hermes
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
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これが含まれている行です)
バージョンアップされるのを待つしかないです。
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.
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.
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!
ViewStyle
how exactly does one patch a package?