У меня есть ссылка ScrollView
:
const childRef = React.useRef<null | ScrollView>(null);
<ScrollView
onScroll={() => {
childRef.current?.calcYOffset();
}}
Однако calcYOffset
выдает мне эту ошибку:
TS2339: свойство calcYOffset не существует в введите 'ScrollView'.
Ссылка прикреплена в дочернем компоненте:
const containerViewRef = React.useRef<View>(null);
React.useImperativeHandle(ref, () => ({
calcYOffset: () => {
containerViewRef.current?.measure(
(
x: any,
y: any,
width: any,
height: any,
pageX: any,
pageY: React.SetStateAction<number>,
) => {
setViewYPosition(pageY);
},
);
},
}));