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

Reading from value during component render. Please ensure that you do not access the value property or use get method of a shared value while React is rendering a component. #740

Open
zack-rose opened this issue Dec 7, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@zack-rose
Copy link

[Reanimated] Reading from value during component render. Please ensure that you do not access the value property or use get method of a shared value while React is rendering a component.

This is happening over and over. Is it a problem with the library itself? I don't think I'm doing anything weird in my code:

import Carousel, { ICarouselInstance } from 'react-native-reanimated-carousel';

  <Carousel
    ref={ref as MutableRefObject<ICarouselInstance | null>}
    data={data || []}
    renderItem={({ item }) => (
      <View style={styles.featuredSlide}>
       
        <Image
          style={[styles.featuredImage, { width: imageWidth, height: imageHeight }]} 
          source={{ uri: item.photos?.[0] || 'https://via.placeholder.com/350x480' }}
        />

        {
          showOverlaidText && (
            <>
              <Text style={styles.a}>{item.a}</Text>
              <Text style={styles.b}>{item.b}</Text>
            </>
          )
        }
      </View>
    )}
    width={width}
    height={height}
    scrollAnimationDuration={scrollAnimationDuration}
    autoPlay={autoPlay}
    loop={loop}
    panGestureHandlerProps={{
      activeOffsetX: [-10, 10],
    }}
  />

I tried the code above. It renders fine. But Im getting thousands of these errors : [Reanimated] Reading from value during component render. Please ensure that you do not access the value property or use get method of a shared value while React is rendering a component.

I did try updating to the latest version. The component is wrapped in a ScrollView. I had to add the panGestureHandlerProps as I was unable to continue to scroll down the page without it when on the carousel

@zack-rose zack-rose added the bug Something isn't working label Dec 7, 2024
Copy link

dosubot bot commented Dec 7, 2024

Hey @zack-rose! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this issue together!

The error message "[Reanimated] Reading from value during component render" is likely related to an issue with the react-native-reanimated-carousel library itself. A patch was made to the library to address this specific warning by removing shared value access during component rendering. Updating to the latest version of the library where this patch is applied should resolve the warning. The patch is included in version 4.0.0-canary.18 of react-native-reanimated-carousel [1][2].

If you have already updated to this version and are still experiencing the issue, ensure that all dependencies are correctly updated and that there are no conflicting versions of react-native-reanimated in your project.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@shuo-hiwintech
Copy link

+1

"react-native": "0.76.2",
"react-native-reanimated": "^3.16.2",
"react-native-gesture-handler": "^2.21.2",
"react-native-reanimated-carousel": "^3.5.1",

@shuo-hiwintech
Copy link

Using npm i [email protected], everything looks fine, no error messages

@zack-rose
Copy link
Author

Thanks I'll have a look. canary.18 made the slideshow buggy

@nmassey
Copy link
Contributor

nmassey commented Dec 11, 2024

hi @zack-rose - yes, it looks like this issue might be a dupe of issue #706 which should be fixed with PR #710.

If there's a new bug in canary.18 (or higher), please do report that separately. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants