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

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

Open
yigitGoldtag opened this issue May 15, 2024 · 12 comments

Comments

@yigitGoldtag
Copy link

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 (

<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()}


);
};

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
Copy link

soshi1234 commented May 15, 2024

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
Copy link
Author

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
Copy link

aguidad commented May 16, 2024

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
Copy link
Author

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
Copy link

ViewStyle

how exactly does one patch a package?

@AbdulBasit-Kagzi
Copy link

I am facing the same issue

@aguidad
Copy link

aguidad commented May 21, 2024

ViewStyle

how exactly does one patch a package?

look at the doc patch-package

@mkalavishvili99
Copy link

I am facing the same issue

already fix this problem ? if you fix please help me

@nomilogic
Copy link

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

@quaddss52
Copy link

ViewStyle

how exactly does one patch a package?

look at the doc patch-package

thanks, my issue is resolved

@rmelara-designli
Copy link

@aguidad solution works, thank you

samholmes added a commit to EdgeApp/edge-react-gui that referenced this issue Jun 5, 2024
Use the patch file from meliorence/react-native-snap-carousel#1017 (comment)
to fix broken package until update.
@nomilogic
Copy link

nomilogic commented Jun 5, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants