Skip to content

Commit 6f5c9a5

Browse files
authored
Merge pull request #310 from react-native-community/lu-fix
[useInteractionManager] Cleanup promise on unmount
2 parents 1082caa + cf7fe56 commit 6f5c9a5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/useInteractionManager.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import {useEffect, useState} from 'react'
22
import {InteractionManager} from 'react-native'
33

44
export function useInteractionManager() {
5-
const [complete, updateInteractionStatus] = useState(false)
5+
const [complete, setComplete] = useState(false)
66

77
useEffect(() => {
8-
InteractionManager.runAfterInteractions(() => {
9-
updateInteractionStatus(true)
8+
const interactionPromise = InteractionManager.runAfterInteractions(() => {
9+
setComplete(true)
1010
})
11+
12+
return () => interactionPromise.cancel()
1113
}, [])
14+
1215
return complete
1316
}

0 commit comments

Comments
 (0)