Create codemod for addressing ESLint warnings (#10032)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import {useEffect, useRef, useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import Animated, {
|
||||
Easing,
|
||||
@@ -105,14 +105,14 @@ export function CountWheel({
|
||||
// animation
|
||||
// The initial entering/exiting animations will get skipped, since these will happen on screen mounts and would
|
||||
// be unnecessary
|
||||
const [key, setKey] = React.useState(0)
|
||||
const [prevCount, setPrevCount] = React.useState(likeCount)
|
||||
const prevIsLiked = React.useRef(isLiked)
|
||||
const [key, setKey] = useState(0)
|
||||
const [prevCount, setPrevCount] = useState(likeCount)
|
||||
const prevIsLiked = useRef(isLiked)
|
||||
const formatPostStatCount = useFormatPostStatCount()
|
||||
const formattedCount = formatPostStatCount(likeCount)
|
||||
const formattedPrevCount = formatPostStatCount(prevCount)
|
||||
|
||||
React.useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (isLiked === prevIsLiked.current) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import {useEffect, useRef, useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {useReducedMotion} from 'react-native-reanimated'
|
||||
|
||||
@@ -49,16 +49,16 @@ export function CountWheel({
|
||||
const shouldAnimate = !useReducedMotion() && hasBeenToggled
|
||||
const shouldRoll = decideShouldRoll(isLiked, likeCount)
|
||||
|
||||
const countView = React.useRef<HTMLDivElement>(null)
|
||||
const prevCountView = React.useRef<HTMLDivElement>(null)
|
||||
const countView = useRef<HTMLDivElement>(null)
|
||||
const prevCountView = useRef<HTMLDivElement>(null)
|
||||
|
||||
const [prevCount, setPrevCount] = React.useState(likeCount)
|
||||
const prevIsLiked = React.useRef(isLiked)
|
||||
const [prevCount, setPrevCount] = useState(likeCount)
|
||||
const prevIsLiked = useRef(isLiked)
|
||||
const formatPostStatCount = useFormatPostStatCount()
|
||||
const formattedCount = formatPostStatCount(likeCount)
|
||||
const formattedPrevCount = formatPostStatCount(prevCount)
|
||||
|
||||
React.useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (isLiked === prevIsLiked.current) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import {useMemo, useState} from 'react'
|
||||
import {type ColorValue, Dimensions, StyleSheet, View} from 'react-native'
|
||||
import {Gesture, GestureDetector} from 'react-native-gesture-handler'
|
||||
import Animated, {
|
||||
@@ -50,7 +50,7 @@ export function GestureActionView({
|
||||
)
|
||||
}
|
||||
|
||||
const [activeAction, setActiveAction] = React.useState<
|
||||
const [activeAction, setActiveAction] = useState<
|
||||
'leftFirst' | 'leftSecond' | 'rightFirst' | 'rightSecond' | null
|
||||
>(null)
|
||||
|
||||
@@ -231,7 +231,7 @@ export function GestureActionView({
|
||||
}
|
||||
})
|
||||
|
||||
const leftSideInterpolation = React.useMemo(() => {
|
||||
const leftSideInterpolation = useMemo(() => {
|
||||
return createInterpolation({
|
||||
firstColor: actions.leftFirst?.color,
|
||||
secondColor: actions.leftSecond?.color,
|
||||
@@ -241,7 +241,7 @@ export function GestureActionView({
|
||||
})
|
||||
}, [actions.leftFirst, actions.leftSecond])
|
||||
|
||||
const rightSideInterpolation = React.useMemo(() => {
|
||||
const rightSideInterpolation = useMemo(() => {
|
||||
return createInterpolation({
|
||||
firstColor: actions.rightFirst?.color,
|
||||
secondColor: actions.rightSecond?.color,
|
||||
@@ -251,14 +251,14 @@ export function GestureActionView({
|
||||
})
|
||||
}, [actions.rightFirst, actions.rightSecond])
|
||||
|
||||
const interpolation = React.useMemo<{
|
||||
const interpolation = useMemo<{
|
||||
inputRange: number[]
|
||||
outputRange: ColorValue[]
|
||||
}>(() => {
|
||||
if (!actions.leftFirst) {
|
||||
return rightSideInterpolation!
|
||||
return rightSideInterpolation
|
||||
} else if (!actions.rightFirst) {
|
||||
return leftSideInterpolation!
|
||||
return leftSideInterpolation
|
||||
} else {
|
||||
return {
|
||||
inputRange: [
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type React from 'react'
|
||||
|
||||
export function GestureActionView({children}: {children: React.ReactNode}) {
|
||||
return children
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import {useEffect, useRef} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {useReducedMotion} from 'react-native-reanimated'
|
||||
|
||||
@@ -50,13 +50,13 @@ export function AnimatedLikeIcon({
|
||||
const t = useTheme()
|
||||
const size = big ? 22 : 18
|
||||
const shouldAnimate = !useReducedMotion() && hasBeenToggled
|
||||
const prevIsLiked = React.useRef(isLiked)
|
||||
const prevIsLiked = useRef(isLiked)
|
||||
|
||||
const likeIconRef = React.useRef<HTMLDivElement>(null)
|
||||
const circle1Ref = React.useRef<HTMLDivElement>(null)
|
||||
const circle2Ref = React.useRef<HTMLDivElement>(null)
|
||||
const likeIconRef = useRef<HTMLDivElement>(null)
|
||||
const circle1Ref = useRef<HTMLDivElement>(null)
|
||||
const circle2Ref = useRef<HTMLDivElement>(null)
|
||||
|
||||
React.useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (prevIsLiked.current === isLiked) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user