Skip to content

Conversation

@Latropos
Copy link
Contributor

@Latropos Latropos commented Mar 19, 2024

Summary

In this comment #5345 (comment):

Unfortunately, with current implementation handlers provided by useAnimatedScrollHandler or any other handlers that are an instance of WorkletEventHandler, that being: useScrollViewOffset, useEvent and useAnimatedGestureHandler (last one deprecated) are supposed to be passed to only one component. This is because their class instances keep the data of the latest component only. Passing them to multiple components leads to undefined behavior.

we mention that event handlers cannot be used with more than one component. This should be documented.

Handler Screenshot Where in docs
useAnimatedScrollHandler image Section "remarks"
useScrollViewOffset image Section "remarks"
useEvent image Section "returns"
useAnimatedGestureHandler Deprecated ❌ No documentation ❌

Test plan

@Latropos Latropos marked this pull request as ready for review March 19, 2024 08:56
@Latropos Latropos requested a review from tjzel March 19, 2024 08:56
Copy link
Collaborator

@tjzel tjzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though useEvent doesn't have a high-quality documentation, I think we should add it there so we don't forget it later on.

Regarding useScrollViewOffset, I think we should add to the remarks section that the animatedRef parameter there mustn't be changed. E.g.

useScrollViewOffset(someState ? animatedRef1 : animatedRef2)

@Latropos Latropos requested a review from tjzel March 20, 2024 12:49
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

Successfully merging this pull request may close these issues.

2 participants