Skip to content

Commit 9fd8037

Browse files
committed
Fix CircleTimer warnings
1 parent 80a196f commit 9fd8037

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

eslint.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ export default [
212212
'src/components/notification/NotificationView.tsx',
213213
'src/components/progress-indicators/AccountSyncBar.tsx',
214214
'src/components/progress-indicators/CancellableProcessingScene.tsx',
215-
'src/components/progress-indicators/CircleTimer.tsx',
216215
'src/components/progress-indicators/FullScreenLoader.tsx',
217216
'src/components/progress-indicators/LoadingSplashScreen.tsx',
218217
'src/components/progress-indicators/Shimmer.tsx',

src/components/progress-indicators/CircleTimer.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ interface Props {
99

1010
export const TEN_MINUTES = 600
1111

12-
export const CircleTimer: React.FC<Props> = ({ expiration, timeExpired }) => {
12+
export const CircleTimer: React.FC<Props> = props => {
13+
const { expiration, timeExpired } = props
1314
const componentMounted = useRef(true)
1415
const timeoutId = useRef<ReturnType<typeof setTimeout> | null>(null)
1516
const isFocused = useIsFocused()
1617

17-
const timerTick = () => {
18+
const timerTick = (): void => {
1819
if (!componentMounted.current || !isFocused) {
1920
if (timeoutId.current != null) {
2021
clearTimeout(timeoutId.current)
@@ -24,7 +25,7 @@ export const CircleTimer: React.FC<Props> = ({ expiration, timeExpired }) => {
2425
const now = new Date()
2526
const nowMilli = now.getTime()
2627
const expMil = expiration.getTime()
27-
if (expiration && nowMilli >= expMil) {
28+
if (nowMilli >= expMil) {
2829
timeExpired()
2930
return
3031
}
@@ -50,18 +51,12 @@ export const CircleTimer: React.FC<Props> = ({ expiration, timeExpired }) => {
5051
}, [])
5152

5253
useEffect(() => {
53-
if (expiration !== null) {
54-
if (timeoutId.current != null) {
55-
clearTimeout(timeoutId.current)
56-
}
57-
timeoutId.current = setTimeout(timerTick, 1000)
54+
if (timeoutId.current != null) {
55+
clearTimeout(timeoutId.current)
5856
}
57+
timeoutId.current = setTimeout(timerTick, 1000)
5958
// eslint-disable-next-line react-hooks/exhaustive-deps
60-
}, [expiration])
61-
62-
if (!expiration) {
63-
return null
64-
}
59+
}, [])
6560

6661
return <View style={{ width: 1, height: 1 }} />
6762
}

0 commit comments

Comments
 (0)