Hello, what do you think of using `remember(LocalV...
# compose-android
g
Hello, what do you think of using
remember(LocalView.current) {}
in your code? Isn't it problematic to put in the slots inside the ComposeView the whole view in which this ComposeView is in? What do I miss here? 🤔
m
You don't need this, just use it directly. The whole screen should recompose if something from Composition Locals changes (including LocalView)
s
The suggested:
Copy code
val view = LocalView.current
val foo = remember { view... }
Won't re-run the remember if LocalView recomposes and you'll end up referencing the old view inside there. Be careful with that.
m
Hmmm I thought that composition locals are treated in a special way unlike states.
s
Yeah it will re-compose as you say. But you got a remember which does not have it as a key. So it won't magically re-run the remember lambda. All the normal state rules apply here, nothing special with composition locals.
👆 2
👆🏻 1
m
I see thanks!