Skip to content

feat: memoize components to prevent child re-renders#45

Merged
haydenbleasel merged 11 commits intovercel:mainfrom
FranciscoMoretti:chore/memoize-markdown-components
Sep 15, 2025
Merged

feat: memoize components to prevent child re-renders#45
haydenbleasel merged 11 commits intovercel:mainfrom
FranciscoMoretti:chore/memoize-markdown-components

Conversation

@FranciscoMoretti
Copy link
Contributor

@FranciscoMoretti FranciscoMoretti commented Aug 26, 2025

This PR memoizes Markdown components to prevent re-renders in children.

Note: This fix doesn't solve anchor because of how hardern-react-markdown works.

Demo video

Memo.children.mp4

This PR memoizes Markdown components to prevent re-renders in children. I'll include a video.

Start as draft.

Note: This fix doesn't solve `anchor` because of how `hardern-react-markdown` works.
@vercel
Copy link
Contributor

vercel bot commented Aug 26, 2025

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

A member of the Team first needs to authorize it.

@FranciscoMoretti FranciscoMoretti changed the title chore(markdown): memoize components to prevent child re-renders feat: memoize components to prevent child re-renders Aug 26, 2025
@FranciscoMoretti FranciscoMoretti marked this pull request as ready for review August 26, 2025 10:13
@vercel
Copy link
Contributor

vercel bot commented Aug 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
streamdown Ready Ready Preview Comment Sep 5, 2025 3:10pm

@haydenbleasel
Copy link
Contributor

Amazing work @FranciscoMoretti - I'd love to show this as a primary feature on the website. Maybe we can create a new section and have react-scan running? I'll give it a go on this PR.

@haydenbleasel
Copy link
Contributor

Example of react-scan in action

streamdown-memo.mp4

@FranciscoMoretti
Copy link
Contributor Author

The video/GIF would be the easiest way to do it.

The ideal solution would be to apply react-scan to this section. The npm package for react-scan has support for showing renders in a specific component. However, I've found these limitations:

@FranciscoMoretti
Copy link
Contributor Author

@haydenbleasel PR is conflict-free again 👌

Reverted df4c3aca05dd8451c0920cec63b6936672a4c9a5 which had the draft for Memo section in the homepage

…for Markdown elements

- Introduced `ImageComponent` for handling images in Markdown.
- Updated memoization for various Markdown elements to improve performance.
- Cleaned up import statements for consistency.
- Replaced `ImageComponent` with `MemoImg` in the components export.
- This change enhances memoization for image handling in Markdown.
FranciscoMoretti and others added 2 commits September 15, 2025 20:56
Updated streamdown version from patch to minor and added feature to memoize components.
@haydenbleasel
Copy link
Contributor

@FranciscoMoretti with another 🐐 PR 🙏

@haydenbleasel haydenbleasel merged commit 64b5afa into vercel:main Sep 15, 2025
3 of 5 checks passed
own-boldsbrain pushed a commit to own-boldsbrain/streamdown that referenced this pull request Sep 22, 2025
* chore(markdown): memoize components to prevent child re-renders

This PR memoizes Markdown components to prevent re-renders in children. I'll include a video.

Start as draft.

Note: This fix doesn't solve `anchor` because of how `hardern-react-markdown` works.

* changeset

* Draft section

* Revert "Draft section"

This reverts commit df4c3ac.

* fix: remove unused 'node' prop from MemoLi component

* fix imports

* feat: add ImageComponent to components export and update memoization for Markdown elements

- Introduced `ImageComponent` for handling images in Markdown.
- Updated memoization for various Markdown elements to improve performance.
- Cleaned up import statements for consistency.

* fix: update image component to use MemoImg for improved performance

- Replaced `ImageComponent` with `MemoImg` in the components export.
- This change enhances memoization for image handling in Markdown.

* Change streamdown version and memoize components

Updated streamdown version from patch to minor and added feature to memoize components.

---------

Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
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.

3 participants