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

wrap component with createAnimatedComponent #540

Open
francescovenica opened this issue Jan 31, 2024 · 2 comments
Open

wrap component with createAnimatedComponent #540

francescovenica opened this issue Jan 31, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@francescovenica
Copy link

Hello

I'm trying to dynamically change the width & height of the component, in order to do so I'm wrapping the carousel in the Animated.createAnimatedComponent

const AnimatedGallery =
  Animated.createAnimatedComponent<TCarouselProps>(Carousel);

the issue with this is that once I wrap it I get this error:

Argument appears to not be a ReactComponent. Keys: next,prev,getCurrentIndex,scrollTo

Expected behavior
No error thrown

Versions (please complete the following information):
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native-reanimated": "~3.3.0",
"react-native-reanimated-carousel": "3.5.1",
"react-native": "0.72.6",
"react-native-gesture-handler": "~2.12.0",

@francescovenica francescovenica added the bug Something isn't working label Jan 31, 2024
Copy link

dosubot bot commented Jan 31, 2024

🤖

Hey there @francescovenica! 😄 Long time no see in the issue tracker! How have you been?

The error you're encountering is due to the fact that the Carousel component in the react-native-reanimated-carousel library is already a complex component that internally uses the react-native-reanimated library. Wrapping it with Animated.createAnimatedComponent is not necessary and can lead to unexpected behavior or errors.

The Animated.createAnimatedComponent function is typically used to create a component that has animated values and can respond to gestures. However, the Carousel component already has these capabilities. It uses the useDerivedValue hook from react-native-reanimated to create an animated value for the carousel's offset, and it uses the ScrollViewGesture component to respond to gestures.

If you need to animate the Carousel component or respond to its gestures in a specific way, you should do so within the Carousel component itself or by using the Carousel's props and methods. For example, you can use the onScrollEnd and onScrollStart props to respond to the carousel's scroll events, and you can use the scrollTo method to programmatically scroll the carousel.

You can refer to the Carousel component source code for more details.

If you need further assistance or if there's something specific you're trying to achieve with the Carousel component, please provide more details so I can assist you better.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@francescovenica
Copy link
Author

would I be able to animate the height & width of the carousel using a sharedValue?

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

2 participants