Skip to content

Commit 3d6012a

Browse files
authored
Add a scope (#354)
1 parent 3f3ccae commit 3d6012a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/mentalmodel/ThinkingInComposeSnippets.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.Row
2525
import androidx.compose.foundation.lazy.LazyColumn
2626
import androidx.compose.foundation.lazy.items
2727
import androidx.compose.material3.Button
28+
import androidx.compose.material3.Card
2829
import androidx.compose.material3.Checkbox
2930
import androidx.compose.material3.HorizontalDivider
3031
import androidx.compose.material3.MaterialTheme
@@ -108,15 +109,16 @@ fun ListComposable(myList: List<String>) {
108109

109110
// [START android_compose_thinking_in_compose_incorrect]
110111
@Composable
111-
@Deprecated("Example with bug")
112112
fun ListWithBug(myList: List<String>) {
113113
var items = 0
114114

115115
Row(horizontalArrangement = Arrangement.SpaceBetween) {
116116
Column {
117117
for (item in myList) {
118-
Text("Item: $item")
119-
items++ // Avoid! Side-effect of the column recomposing.
118+
Card {
119+
Text("Item: $item")
120+
items++ // Avoid! Side-effect of the column recomposing.
121+
}
120122
}
121123
}
122124
Text("Count: $items")

0 commit comments

Comments
 (0)