remove most uses of import * as React

This commit is contained in:
Samuel Newman
2025-05-26 18:12:05 +03:00
parent adb3c82d7c
commit 8de4c2db61
4 changed files with 9 additions and 42 deletions
+2 -2
View File
@@ -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<Animated.Value>(undefined)
const lazyRef = useRef<Animated.Value>(undefined)
if (lazyRef.current === undefined) {
lazyRef.current = new Animated.Value(initialValue)
-32
View File
@@ -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 | NodeJS.Timeout>(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]
}
@@ -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])
@@ -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) => {