Skip to content

Commit 866b4ee

Browse files
AndreiCalazansgorhom
authored andcommitted
fix: replace getRefNativeTag with findNodeHandle (#1823)(by @AndreiCalazans)
1 parent 08db4ab commit 866b4ee

File tree

4 files changed

+7
-50
lines changed

4 files changed

+7
-50
lines changed

src/hooks/useScrollHandler.web.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useEffect, useRef, TouchEvent } from 'react';
2+
import { findNodeHandle } from 'react-native';
23
import { useSharedValue } from 'react-native-reanimated';
34
import { useBottomSheetInternal } from './useBottomSheetInternal';
45
import { ANIMATION_STATE, SCROLLABLE_STATE } from '../constants';
5-
import { getRefNativeTag } from '../utilities/getRefNativeTag';
66
import type { Scrollable } from '../types';
77

88
export type ScrollEventContextType = {
@@ -12,7 +12,7 @@ export type ScrollEventContextType = {
1212

1313
export const useScrollHandler = () => {
1414
//#region refs
15-
const scrollableRef = useRef<Scrollable>();
15+
const scrollableRef = useRef<Scrollable>(null);
1616
//#endregion
1717

1818
//#region variables
@@ -29,7 +29,7 @@ export const useScrollHandler = () => {
2929

3030
//#region effects
3131
useEffect(() => {
32-
const element = getRefNativeTag(scrollableRef) as any;
32+
const element = findNodeHandle(scrollableRef.current) as any;
3333

3434
var scrollOffset = 0;
3535
var supportsPassive = false;

src/hooks/useScrollable.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, RefObject, useRef } from 'react';
2+
import { findNodeHandle } from 'react-native';
23
import { useSharedValue } from 'react-native-reanimated';
3-
import { getRefNativeTag } from '../utilities/getRefNativeTag';
44
import { SCROLLABLE_STATE, SCROLLABLE_TYPE } from '../constants';
55
import type { ScrollableRef, Scrollable } from '../types';
66

@@ -38,7 +38,7 @@ export const useScrollable = () => {
3838
// find node handle id
3939
let id;
4040
try {
41-
id = getRefNativeTag(ref);
41+
id = findNodeHandle(ref.current);
4242
} catch {
4343
return;
4444
}

src/hooks/useScrollableSetter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useCallback, useEffect } from 'react';
2+
import { findNodeHandle } from 'react-native';
23
import Animated from 'react-native-reanimated';
34
import { useBottomSheetInternal } from './useBottomSheetInternal';
4-
import { getRefNativeTag } from '../utilities/getRefNativeTag';
55
import { SCROLLABLE_TYPE } from '../constants';
66
import type { Scrollable } from '../types';
77

@@ -31,7 +31,7 @@ export const useScrollableSetter = (
3131
isContentHeightFixed.value = false;
3232

3333
// set current scrollable ref
34-
const id = getRefNativeTag(ref);
34+
const id = findNodeHandle(ref.current);
3535
if (id) {
3636
setScrollableRef({
3737
id: id,

src/utilities/getRefNativeTag.ts

-43
This file was deleted.

0 commit comments

Comments
 (0)