Skip to content

Commit

Permalink
add interactiveExample
Browse files Browse the repository at this point in the history
  • Loading branch information
patrycjakalinska committed Aug 7, 2024
1 parent af5bed9 commit de2b701
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions packages/docs-reanimated/docs/advanced/useEvent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,12 @@ The hook returns event handler that will be invoked when native event is dispatc

## Example

```js
function useAnimatedPagerScrollHandler(handlers, dependencies) {
const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);
import useEvent from '@site/src/examples/useHandlerEventExample';
import useEventSrc from '!!raw-loader!@site/src/examples/useHandlerEventExample';

return useEvent(
(event) => {
'worklet';
const { onPageScroll } = handlers;
<InteractiveExample src={useEventSrc} component={useEvent} />

if (onPageScroll && event.eventName.endsWith('onPageScroll')) {
onPageScroll(event, context);
}
},
['onPageScroll'],
doDependenciesDiffer
);
}
```
This example can be more easily implemented using [`useScrollViewOffset`](/docs/scroll/useScrollViewOffset/).

## Remarks

Expand Down

0 comments on commit de2b701

Please sign in to comment.