Skip to content

Conversation

@2hu12
Copy link
Contributor

@2hu12 2hu12 commented Oct 15, 2025

Description

This PR introduces the following changes:

Added the extraIncompleteHandles option

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Refactoring (no functional changes)

Related Issues

Fixes #159 #108
Closes #
Related to #159 #108

Changes Made

Testing

  • All existing tests pass
  • Added new tests for the changes
  • Manually tested the changes

Test Coverage

Screenshots/Demos

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have created a changeset (pnpm changeset)

Changeset

  • I have created a changeset for these changes

Additional Notes

@vercel
Copy link
Contributor

vercel bot commented Oct 15, 2025

@2hu12 is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

? parseIncompleteMarkdown(content.trim(), extraIncompleteHandles)
: content,
[content, shouldParseIncompleteMarkdown]
[content, shouldParseIncompleteMarkdown, extraIncompleteHandles]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Block component memo comparison only checks content but ignores extraIncompleteHandles, causing stale renders when extraIncompleteHandles changes.

View Details
📝 Patch Details
diff --git a/packages/streamdown/index.tsx b/packages/streamdown/index.tsx
index 8921f60..a7636b6 100644
--- a/packages/streamdown/index.tsx
+++ b/packages/streamdown/index.tsx
@@ -103,7 +103,10 @@ const Block = memo(
 
     return <ReactMarkdown {...props}>{parsedContent}</ReactMarkdown>;
   },
-  (prevProps, nextProps) => prevProps.content === nextProps.content
+  (prevProps, nextProps) => 
+    prevProps.content === nextProps.content && 
+    prevProps.shouldParseIncompleteMarkdown === nextProps.shouldParseIncompleteMarkdown &&
+    prevProps.extraIncompleteHandles === nextProps.extraIncompleteHandles
 );
 
 Block.displayName = "Block";
@@ -165,6 +168,7 @@ export const Streamdown = memo(
   (prevProps, nextProps) =>
     prevProps.children === nextProps.children &&
     prevProps.shikiTheme === nextProps.shikiTheme &&
-    prevProps.isAnimating === nextProps.isAnimating
+    prevProps.isAnimating === nextProps.isAnimating &&
+    prevProps.extraIncompleteHandles === nextProps.extraIncompleteHandles
 );
 Streamdown.displayName = "Streamdown";

Analysis

Block component memo comparison ignores extraIncompleteHandles causing stale renders

What fails: The Block component's React.memo comparison function only checks content prop, ignoring extraIncompleteHandles and shouldParseIncompleteMarkdown dependencies used in the component's useMemo hook.

How to reproduce:

  1. Render <Streamdown extraIncompleteHandles={[handler1]}>content</Streamdown>
  2. Re-render with different handlers: <Streamdown extraIncompleteHandles={[handler2]}>content</Streamdown>
  3. Same content, different handlers - component should re-render but doesn't

Result: Block component shows stale parsed content when extraIncompleteHandles changes, because memo comparison returns true (no re-render needed) even though the useMemo dependencies have changed.

Expected: Component should re-render when any useMemo dependency changes, producing different parsed output when handlers change.

Root cause: Both Streamdown and Block memo functions were incomplete:

  • Block memo only checked content but ignored extraIncompleteHandles and shouldParseIncompleteMarkdown
  • Streamdown memo only checked children, shikiTheme, and isAnimating but ignored extraIncompleteHandles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamdown is not working properly only in rendering the mathematical equations. Rest is working fine and perfect.

1 participant