From 1acda81e6c59741c28a5c254004715debee0df45 Mon Sep 17 00:00:00 2001 From: aodavit-d Date: Wed, 2 Nov 2022 18:55:26 +0400 Subject: [PATCH] Fixed typescript errors --- LabelContainer.tsx | 10 +++++++--- hooks.tsx | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/LabelContainer.tsx b/LabelContainer.tsx index 1e36836..80c4996 100644 --- a/LabelContainer.tsx +++ b/LabelContainer.tsx @@ -1,13 +1,17 @@ import React, { PureComponent } from 'react'; import { View } from 'react-native'; -class LabelContainer extends PureComponent { +import type { ViewProps } from 'react-native'; + +class LabelContainer extends PureComponent< + { renderContent: (value: number) => React.ReactNode } & ViewProps +> { state = { value: Number.NaN, }; - - setValue = value => { + + setValue = (value: number) => { this.setState({ value }); } diff --git a/hooks.tsx b/hooks.tsx index 85214b2..06d303a 100644 --- a/hooks.tsx +++ b/hooks.tsx @@ -103,7 +103,10 @@ export const useThumbFollower = ( renderContent: undefined | ((value: number) => ReactNode), isPressed: boolean, allowOverflow: boolean, -) => { +): [ + JSX.Element, + (thumbPositionInView: number, value: number) => void +]|[] => { const xRef = useRef(new Animated.Value(0)); const widthRef = useRef(0); const contentContainerRef = useRef(null); @@ -111,7 +114,7 @@ export const useThumbFollower = ( const {current: x} = xRef; const update = useCallback( - (thumbPositionInView, value) => { + (thumbPositionInView: number, value: number) => { const {current: width} = widthRef; const {current: containerWidth} = containerWidthRef; const position = thumbPositionInView - width / 2; @@ -160,7 +163,7 @@ export const useSelectedRail = ( containerWidthRef: MutableRefObject, thumbWidth: number, disableRange: boolean, -) => { +): [Record, () => void] => { const {current: left} = useRef(new Animated.Value(0)); const {current: right} = useRef(new Animated.Value(0)); const update = useCallback(() => {