From 37c921fe0b1e5a12379d87d69e7a3d59c5db7116 Mon Sep 17 00:00:00 2001 From: storytellerF <34095089+storytellerF@users.noreply.github.com> Date: Sat, 7 Dec 2024 16:19:45 +0800 Subject: [PATCH] fix: recomposition in ContextualFlowRow --- .../kotlin/org/kodein/emoji/compose/text.kt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/emoji-compose/src/commonMain/kotlin/org/kodein/emoji/compose/text.kt b/emoji-compose/src/commonMain/kotlin/org/kodein/emoji/compose/text.kt index 722de57..4a81198 100644 --- a/emoji-compose/src/commonMain/kotlin/org/kodein/emoji/compose/text.kt +++ b/emoji-compose/src/commonMain/kotlin/org/kodein/emoji/compose/text.kt @@ -47,15 +47,10 @@ private fun WithNotoEmoji( append(text.substring(start, found.start)) val inlineContentID = "emoji:${found.emoji}" inlineContent[inlineContentID] = InlineTextContent(Placeholder(found.emoji.ratio().em, 1.em, PlaceholderVerticalAlign.Center)) { - var display: (@Composable () -> Unit)? by remember { mutableStateOf(null) } - LaunchedEffect(null) { - display = createDisplay(found.emoji) - } - if (display == null) { - placeholder(found.emoji) - } else { - display!!.invoke() + val display by produceState<(@Composable () -> Unit)?>(null, found.emoji) { + value = createDisplay(found.emoji) } + display?.invoke() ?: placeholder(found.emoji) } appendInlineContent(inlineContentID) start = found.end