diff --git a/src/lib/hooks/useAnimatedValue.ts b/src/lib/hooks/useAnimatedValue.ts index 9ae14dab62..e7b50ef068 100644 --- a/src/lib/hooks/useAnimatedValue.ts +++ b/src/lib/hooks/useAnimatedValue.ts @@ -1,8 +1,8 @@ -import * as React from 'react' +import {useRef} from 'react' import {Animated} from 'react-native' export function useAnimatedValue(initialValue: number) { - const lazyRef = React.useRef(undefined) + const lazyRef = useRef(undefined) if (lazyRef.current === undefined) { lazyRef.current = new Animated.Value(initialValue) diff --git a/src/lib/hooks/useTimer.ts b/src/lib/hooks/useTimer.ts deleted file mode 100644 index b14a9f24fd..0000000000 --- a/src/lib/hooks/useTimer.ts +++ /dev/null @@ -1,32 +0,0 @@ -import * as React from 'react' - -/** - * Helper hook to run persistent timers on views - */ -export function useTimer(time: number, handler: () => void) { - const timer = React.useRef(undefined) - - // function to restart the timer - const reset = React.useCallback(() => { - if (timer.current) { - clearTimeout(timer.current) - } - timer.current = setTimeout(handler, time) - }, [time, timer, handler]) - - // function to cancel the timer - const cancel = React.useCallback(() => { - if (timer.current) { - clearTimeout(timer.current) - timer.current = undefined - } - }, [timer]) - - // start the timer immediately - React.useEffect(() => { - reset() - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []) - - return [reset, cancel] -} diff --git a/src/view/com/post-thread/PostThreadLoadMore.tsx b/src/view/com/post-thread/PostThreadLoadMore.tsx index 27e2ea724d..157e2af24c 100644 --- a/src/view/com/post-thread/PostThreadLoadMore.tsx +++ b/src/view/com/post-thread/PostThreadLoadMore.tsx @@ -1,18 +1,18 @@ -import * as React from 'react' +import {useMemo} from 'react' import {View} from 'react-native' -import {AppBskyFeedDefs, AtUri} from '@atproto/api' +import {type AppBskyFeedDefs, AtUri} from '@atproto/api' import {Trans} from '@lingui/macro' import {makeProfileLink} from '#/lib/routes/links' +import {Link} from '#/view/com/util/Link' +import {UserAvatar} from '#/view/com/util/UserAvatar' import {atoms as a, useTheme} from '#/alf' import {Text} from '#/components/Typography' -import {Link} from '../util/Link' -import {UserAvatar} from '../util/UserAvatar' export function PostThreadLoadMore({post}: {post: AppBskyFeedDefs.PostView}) { const t = useTheme() - const postHref = React.useMemo(() => { + const postHref = useMemo(() => { const urip = new AtUri(post.uri) return makeProfileLink(post.author, 'post', urip.rkey) }, [post.uri, post.author]) diff --git a/src/view/shell/createNativeStackNavigatorWithAuth.tsx b/src/view/shell/createNativeStackNavigatorWithAuth.tsx index 1c32971d42..701d32f70b 100644 --- a/src/view/shell/createNativeStackNavigatorWithAuth.tsx +++ b/src/view/shell/createNativeStackNavigatorWithAuth.tsx @@ -1,4 +1,4 @@ -import * as React from 'react' +import {useEffect} from 'react' import {View} from 'react-native' // Based on @react-navigation/native-stack/src/navigators/createNativeStackNavigator.ts // MIT License @@ -75,8 +75,7 @@ function NativeStackNavigator({ screenOptions, screenLayout, }) - - React.useEffect( + useEffect( () => // @ts-expect-error: there may not be a tab navigator in parent navigation?.addListener?.('tabPress', (e: any) => {