Skip to content

Commit db7eeaf

Browse files
Use delegation
1 parent 4ecbd06 commit db7eeaf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/jsMain/kotlin/App.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import kotlinx.coroutines.*
66
private val scope = MainScope()
77

88
val app = fc<Props> {
9-
val (shoppingList, setShoppingList) = useState(emptyList<ShoppingListItem>())
9+
var shoppingList by useState(emptyList<ShoppingListItem>())
1010

1111
useEffectOnce {
1212
scope.launch {
13-
setShoppingList(getShoppingList())
13+
shoppingList = getShoppingList()
1414
}
1515
}
1616

@@ -24,7 +24,7 @@ val app = fc<Props> {
2424
attrs.onClickFunction = {
2525
scope.launch {
2626
deleteShoppingListItem(item)
27-
setShoppingList(getShoppingList())
27+
shoppingList = getShoppingList()
2828
}
2929
}
3030
+"[${item.priority}] ${item.desc} "
@@ -36,7 +36,7 @@ val app = fc<Props> {
3636
val cartItem = ShoppingListItem(input.replace("!", ""), input.count { it == '!' })
3737
scope.launch {
3838
addShoppingListItem(cartItem)
39-
setShoppingList(getShoppingList())
39+
shoppingList = getShoppingList()
4040
}
4141
}
4242
}

0 commit comments

Comments
 (0)