Skip to content

Instantly share code, notes, and snippets.

@skydoves
Last active August 8, 2024 08:31
Show Gist options
  • Save skydoves/565ac648ba8f464630c73097039848d5 to your computer and use it in GitHub Desktop.
Save skydoves/565ac648ba8f464630c73097039848d5 to your computer and use it in GitHub Desktop.
user_profiles_state_hoisting
@Composable
fun UserProfiles(
userList: List<User>,
onUserClick: (User) -> Unit
) {
// Composable logic here
}
@Composable
fun ParentComposable(viewModel: UserViewModel = viewModel()) {
val userList by viewModel.userList.collectAsStateWithLifecycle()
UserProfiles(
userList = userList,
onUserClick = { user -> viewModel.onUserClick(user) }
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment