Pick the fix
A teammate calls api.track("screen_view") directly in a composable's body. What's the problem and the fix?
Hint 1 of 1
How many times can a composable body run?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A The body can run many times; move it into LaunchedEffect(Unit)
Correct. Effects run once per entry into composition, not on every recomposition.
Why not the others?
- B It's fine; composables run once. Composables re-run whenever state they read changes.
- C Move it into
remember { }. remember caches a value; using it for side effects is a hack and not cancellable. - D Wrap it in
Modifier.clickable. That only runs on a tap.