File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,33 @@ val markdownState = rememberMarkdownState(markdown)
158158val markdownState = rememberMarkdownState(markdown, immediate = true )
159159```
160160
161+ #### Retaining State During Updates
162+
163+ By default, when the markdown content changes, the component shows a loading state while parsing the
164+ new content. You can use the ` retainState ` parameter to keep the previous rendered content visible
165+ while the new content is being parsed:
166+
167+ ``` kotlin
168+ // Retain previous content during updates (avoids showing loading state)
169+ val markdownState = rememberMarkdownState(
170+ markdown,
171+ retainState = true
172+ )
173+ Markdown (markdownState)
174+
175+ // With dynamic content loading
176+ val markdownState = rememberMarkdownState(
177+ key, // key that triggers re-parsing
178+ retainState = true
179+ ) {
180+ " # Dynamic content $counter "
181+ }
182+ Markdown (markdownState)
183+ ```
184+
185+ This is particularly useful when content updates frequently or when you want to avoid flickering
186+ between the old content and the loading state.
187+
161188### Lazy Loading for Large Documents
162189
163190Since version 0.33.0, the library supports rendering large markdown documents efficiently using
You can’t perform that action at this time.
0 commit comments