Skip to content

Commit 09c35df

Browse files
committed
React. Use awaitCancellation
1 parent 6d92d3e commit 09c35df

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

kotlin-react-use/src/jsMain/kotlin/react/use/useEventListener.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package react.use
22

3+
import js.coroutines.awaitCancellation
34
import react.useEffect
45
import web.events.*
56

@@ -17,7 +18,7 @@ fun <E : Event> useEventListener(
1718
useEffect(target, type) {
1819
target ?: return@useEffect
1920

20-
awaitCleanup(
21+
awaitCancellation(
2122
target.addEventHandler(
2223
type = type,
2324
options = options,

kotlin-react-use/src/jsMain/kotlin/react/use/useUnmountEffect.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package react.use
22

3+
import js.coroutines.awaitCancellation
34
import react.useEffectOnce
45

56
/**
@@ -11,6 +12,6 @@ fun useUnmountEffect(
1112
val latestCallback by useLatest(callback)
1213

1314
useEffectOnce {
14-
awaitCleanup(latestCallback)
15+
awaitCancellation(latestCallback)
1516
}
1617
}

0 commit comments

Comments
 (0)