https://kotlinlang.org logo
#compose
Title
# compose
v

Vlad

11/01/2023, 11:06 AM
Is it bad idea to provide into Local composition the SnackbarHostState at top of the tree, so I can easily access it anywhere down the tree and easily show snackbars within app scope rather then screen scope?
j

Jamil

11/01/2023, 9:50 PM
Hey Vlad, I'd first consider trying to hoist the SnackbarHostState to the lowest common ancestor (https://developer.android.com/jetpack/compose/state-hoisting). If this doesn't suit your needs and you want it at the top of the tree, I wouldn't necessarily say its a bad idea. I'd personally look for a really good reason (requirement) to do so.
2 Views