Skip to content

Commit

Permalink
Use LaunchedEffect instead of scope.launch()
Browse files Browse the repository at this point in the history
  • Loading branch information
codeguru42 committed Aug 8, 2023
1 parent f51cd32 commit 3b4de05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/codeguru/gocapture/ui/ImageScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -37,7 +38,6 @@ fun ImageScreen(navController: NavHostController, modifier: Modifier, imageUri:
val repository = GoCaptureRepository(LocalContext.current as Activity)
val (isProcessing, setIsProcessing) = remember { mutableStateOf(false) }
val snackbarHostState = remember { SnackbarHostState() }
val scope = rememberCoroutineScope()
val (errorMessage, setErrorMessage) = remember<MutableState<String?>> { mutableStateOf("") }

Scaffold(
Expand All @@ -57,7 +57,7 @@ fun ImageScreen(navController: NavHostController, modifier: Modifier, imageUri:
}

if (!errorMessage.isNullOrEmpty()) {
scope.launch {
LaunchedEffect(snackbarHostState) {
snackbarHostState.showSnackbar(errorMessage)
}
}
Expand Down

0 comments on commit 3b4de05

Please sign in to comment.