Skip to content

Commit

Permalink
Optimize the usage of conditional LaunchedEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasipek committed Dec 12, 2023
1 parent 036d75e commit 73d5e0d
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,17 @@ fun OhTeePeeInput(
focusManager.moveFocus(direction)
}

LaunchedEffect(autoFocusByDefault) {
if (autoFocusByDefault) {
if (autoFocusByDefault) {
LaunchedEffect(Unit) {
val focusIndex = value.trim().length
focusRequester[focusIndex].requestFocusSafely()
}
}

LaunchedEffect(isValueInvalid) {
if (isValueInvalid) focusRequester.first().requestFocus()
if (isValueInvalid) {
LaunchedEffect(Unit) {
focusRequester.first().requestFocus()
}
}

OhTeePeeInput(
Expand Down

0 comments on commit 73d5e0d

Please sign in to comment.