import androidx.compose.runtime.Composableimport org.jetbrains.compose.reload.isHotReloadActive@Composablefun App() { // Show development tools only during hot reload if (isHotReloadActive) { DevelopmentToolbar() } MainContent()}// Adjust logging levelfun configureLogging() { val level = if (isHotReloadActive) LogLevel.DEBUG else LogLevel.INFO Logger.setLevel(level)}// Enable expensive validation checksfun validateState() { if (isHotReloadActive) { performExpensiveValidation() }}
When the composable enters the composition, the hook is registered
The hook remains active as long as the composable is in the composition
When the composable leaves the composition, the hook is automatically cleaned up
Automatic CleanupUnlike staticHotReloadScope.invokeAfterHotReload(), AfterHotReloadEffect automatically unregisters the hook when the composable leaves the composition. You don’t need to manually manage cleanup.
import androidx.compose.runtime.Composableimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.rememberimport androidx.compose.runtime.setValueimport org.jetbrains.compose.reload.AfterHotReloadEffectimport org.jetbrains.compose.reload.DelicateHotReloadApi@OptIn(DelicateHotReloadApi::class)@Composablefun DataDisplay(repository: DataRepository) { var data by remember { mutableStateOf(repository.getData()) } AfterHotReloadEffect { // Refresh data after hot reload data = repository.getData() } Text("Data: $data")}
A legacy composable function that provides an entry point for hot reload.
@Composable@DelicateHotReloadApi@Deprecated("DevelopmentEntryPoint {} is no longer needed and the default dependency will be removed soon")public expect fun DevelopmentEntryPoint(child: @Composable () -> Unit)
DeprecatedThis function is deprecated and no longer necessary. When using regular Compose Window components, there is no need to manually wrap code with DevelopmentEntryPoint.