# compose

Chris Johnson

03/03/2022, 12:07 AM
Compose internally is saying there's something wrong with how I'm using the focus api. Code in 🧵
I'm specifying this modifier on my TextField
Copy code
    .onFocusChanged {
        if (isFocused) {
    }.focusable(enabled = !isLoading, interactionSource = interactionSource)
and I get this error
Copy code
java.lang.IllegalStateException: Compose Runtime internal error. Unexpected or incorrect use of the Compose internal runtime API (Use active SlotWriter to determine anchor location instead). Please report to Google or use <>
When trying to focus my TextField when it's done loading. My use case is I don't want to allow focus on my TextField until data has finished loading and at that point they can click into it and start typing. isLoading is a boolean on my uiState that gets changed in the viewModel. To me the above seems pretty intuitive. If we're not loading, then listen for isFocused changes and respond. I guess it gets tripped up when
is true but you try to focus the TextField. That's when I get the crash. Is there a better way to do this?

Chuck Jazdzewski [G]

03/03/2022, 12:48 AM
This error almost always due to a bug in the Compose implementation, not how you are using it. Consider filing a bug with a repro project attached.
This particular error is probably due to a separate thread trying to invalidate the composition which was unsafe to do in 1.1 but I fixed in 1.2.
🙇🏼 1
🙇 1

Chris Johnson

03/03/2022, 12:51 AM
I was wondering if it was something that would be fixed in a later version. I was going to try that next. Currently on 1.1.0-beta02. Let me try and upgrade and see if that helps. If not I'll file a bug, Thank you!
👀 2
Haven't had a chance to go back and check on this 😞 will try and update when I know more