Pick the fix
A team passes the screen's ViewModel through a CompositionLocal to avoid parameters. What's the best guidance?
Hint 1 of 1
What does a preview of a child need to provide?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Pass state and lambdas as parameters; keep CompositionLocal for tree-wide values like theme
Correct. Explicit parameters keep dependencies visible and previews simple.
Why not the others?
- B Switch to staticCompositionLocalOf. That changes recomposition, not the design problem.
- C Make the ViewModel a global object. That's worse: shared, untestable state.
- D It's the recommended pattern. Compose guidance warns against hiding dependencies this way.