Skip to content

Commit 1ad09f4

Browse files
author
aerialist7
committed
Remove useEffectWithCleanup hook
1 parent 57ca268 commit 1ad09f4

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/main/kotlin/hook/useEffectWithCleanup.kt

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/main/kotlin/hook/useUsers.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ import kotlinx.browser.window
55
import kotlinx.coroutines.GlobalScope
66
import kotlinx.coroutines.await
77
import kotlinx.coroutines.launch
8+
import react.useEffect
89
import react.useState
910

1011
fun useUsers(): Users {
1112
var data by useState<Users>(emptyArray())
1213

13-
useEffectWithCleanup {
14+
useEffect {
1415
val job = GlobalScope.launch {
1516
data = getUsers()
1617
}
17-
job::cancel
18+
cleanup(job::cancel)
1819
}
1920

2021
return data

0 commit comments

Comments
 (0)