Enforce using named imports from 'react' (#10259)

This commit is contained in:
DS Boyce
2026-04-15 10:11:09 -07:00
committed by GitHub
parent 19e2dc939a
commit b9561f78ee
5 changed files with 25 additions and 17 deletions
+3 -3
View File
@@ -1,12 +1,12 @@
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)
}
return lazyRef.current as Animated.Value
return lazyRef.current
}
+5 -5
View File
@@ -1,13 +1,13 @@
import * as React from 'react'
import {useCallback, useEffect, useRef} 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)
const timer = useRef<undefined | NodeJS.Timeout>(undefined)
// function to restart the timer
const reset = React.useCallback(() => {
const reset = useCallback(() => {
if (timer.current) {
clearTimeout(timer.current)
}
@@ -15,7 +15,7 @@ export function useTimer(time: number, handler: () => void) {
}, [time, timer, handler])
// function to cancel the timer
const cancel = React.useCallback(() => {
const cancel = useCallback(() => {
if (timer.current) {
clearTimeout(timer.current)
timer.current = undefined
@@ -23,7 +23,7 @@ export function useTimer(time: number, handler: () => void) {
}, [timer])
// start the timer immediately
React.useEffect(() => {
useEffect(() => {
reset()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])