feat!: prevent FlatList item re-rendering - #1080
Open
gmsgowtham wants to merge 2 commits into
Open
Conversation
Performance Comparison ReportSignificant Changes To DurationShow entries
Show details
Meaningless Changes To DurationThere are no entries Render Count ChangesThere are no entries Render IssuesThere are no entries Added EntriesThere are no entries Removed EntriesThere are no entries Stability
|
- Introduce MarkdownBlock (id+token+raw) with content-hash keys via useMarkdownBlocks (src/hooks/useMarkdownBlocks.ts:10, src/lib/types.ts:17) replacing index keys (src/lib/Markdown.tsx:44) - Memoize block rows with React.memo and raw/type comparators (src/lib/MarkdownBlock.tsx:24) so only changed/new blocks re-parse - Refactor Markdown to data=MarkdownBlock[] with stable FlatList keyExtractor and ScrollView fallback when flatListProps=null (src/lib/Markdown.tsx:31,51) - Optimize useMarkdown with token-level reuse for append and per-index edits (src/hooks/useMarkdown.ts:84,125) - Stabilize ReactComponentTokenizer keys and add Renderer.resetKeys (src/hooks/useMarkdownWithComponents.tsx:39, src/lib/Renderer.tsx:13) - Update docs, exports and snapshots; fixes #451 BREAKING CHANGE: Markdown flatListProps generic is now FlatListProps<MarkdownBlock> | null; snapshots change; callers should memoize styles/theme/renderer objects to benefit from bail-out
gmsgowtham
force-pushed
the
fix/451-prevent-flatlist-rerender
branch
from
September 6, 2026 10:14
71297c6 to
825fee6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #451
Root cause
Markdown used data=ReactNode[] + index keys (src/lib/Markdown.tsx:30) causing every value change to recreate all identities and FlatList to re-render all rows. Unstable styles/renderer and global slugger counter amplified.
Changes
resetKeys() (src/lib/Renderer.tsx:13), useMarkdownWithComponents stable ids (src/hooks/useMarkdownWithComponents.tsx:39)
Verification
BREAKING CHANGE: flatListProps generic is FlatListProps|null; snapshots change; callers should memoize styles/theme/renderer.