Skip to content

Conversation

@hirbod
Copy link
Contributor

@hirbod hirbod commented Oct 23, 2024

Motivation

The current useScrollHandler.web.ts implementation passes undefined as scrollHandler on web, thus breaking onEndReached. This PR fixes the problem.

Found by my brother @intergalacticspacehighway, thanks 👑 - creating PR on his behalf!

@hirbod hirbod changed the title fix:(web) useScrollHandler.web.ts fix:(web) useScrollHandler.web.ts does not pass scrollHandler, thus onEndReached fails to trigger Oct 23, 2024
@hirbod
Copy link
Contributor Author

hirbod commented Oct 24, 2024

Here is a working patch until this is merged and released

diff --git a/lib/commonjs/hooks/useScrollHandler.web.js b/lib/commonjs/hooks/useScrollHandler.web.js
index 389e438c492c6f72c70e1af888d6b1d2af04cb0e..4540a2a43e5ba8b1e43f67e590eaf9eced0898d4 100644
--- a/lib/commonjs/hooks/useScrollHandler.web.js
+++ b/lib/commonjs/hooks/useScrollHandler.web.js
@@ -9,7 +9,7 @@ var _reactNative = require("react-native");
 var _reactNativeReanimated = require("react-native-reanimated");
 var _constants = require("../constants");
 var _useBottomSheetInternal = require("./useBottomSheetInternal");
-const useScrollHandler = () => {
+const useScrollHandler = (_, onScroll) => {
   //#region refs
   const scrollableRef = (0, _react.useRef)(null);
   //#endregion
@@ -117,7 +117,7 @@ const useScrollHandler = () => {
   //#endregion
 
   return {
-    scrollHandler: undefined,
+    scrollHandler: onScroll,
     scrollableRef,
     scrollableContentOffsetY
   };
diff --git a/lib/module/hooks/useScrollHandler.web.js b/lib/module/hooks/useScrollHandler.web.js
index ff23391ebb20669c0ef6462b8ab250c40b992a64..d0329aef938238b4bda3cd223fae6689da5da766 100644
--- a/lib/module/hooks/useScrollHandler.web.js
+++ b/lib/module/hooks/useScrollHandler.web.js
@@ -3,7 +3,7 @@ import { findNodeHandle } from 'react-native';
 import { useSharedValue } from 'react-native-reanimated';
 import { ANIMATION_STATE, SCROLLABLE_STATE } from '../constants';
 import { useBottomSheetInternal } from './useBottomSheetInternal';
-export const useScrollHandler = () => {
+export const useScrollHandler = (_, onScroll) => {
   //#region refs
   const scrollableRef = useRef(null);
   //#endregion
@@ -111,7 +111,7 @@ export const useScrollHandler = () => {
   //#endregion
 
   return {
-    scrollHandler: undefined,
+    scrollHandler: onScroll,
     scrollableRef,
     scrollableContentOffsetY
   };
diff --git a/src/hooks/useScrollHandler.web.ts b/src/hooks/useScrollHandler.web.ts
index a699a8a1f6e03556f84adf79bc3c538a64aea2c4..fb050b2c198f719077fc383850ac23e202f4f679 100644
--- a/src/hooks/useScrollHandler.web.ts
+++ b/src/hooks/useScrollHandler.web.ts
@@ -10,7 +10,7 @@ export type ScrollEventContextType = {
   shouldLockInitialPosition: boolean;
 };
 
-export const useScrollHandler = () => {
+export const useScrollHandler = (_, onScroll) => {
   //#region refs
   const scrollableRef = useRef<Scrollable>(null);
   //#endregion
@@ -168,7 +168,7 @@ export const useScrollHandler = () => {
   //#endregion
 
   return {
-    scrollHandler: undefined,
+    scrollHandler: onScroll,
     scrollableRef,
     scrollableContentOffsetY,
   };

@hirbod
Copy link
Contributor Author

hirbod commented Oct 25, 2024

@gorhom chance to take a look?

@gorhom gorhom self-assigned this Oct 26, 2024
@gorhom gorhom added the v5 label Oct 26, 2024
@gorhom gorhom merged commit 331dafa into gorhom:master Oct 26, 2024
@gorhom
Copy link
Owner

gorhom commented Oct 26, 2024

thanks @hirbod for spotting and submitting the PR <3

@hirbod
Copy link
Contributor Author

hirbod commented Oct 26, 2024

Welcome. By the way, not included in the release changelog

@hirbod hirbod deleted the patch-1 branch October 26, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants