Skip to content

fix: resolve ImageBlock render loop caused by useResponsiveContainer oscillation - #279

Merged
ankit-thesys merged 3 commits into
thesysdev:mainfrom
ankit-thesys:fix/imageBlock
Mar 9, 2026
Merged

fix: resolve ImageBlock render loop caused by useResponsiveContainer oscillation#279
ankit-thesys merged 3 commits into
thesysdev:mainfrom
ankit-thesys:fix/imageBlock

Conversation

@ankit-thesys

Copy link
Copy Markdown
Contributor

Summary

  • Fixed width oscillation loop in ImageBlock: The useResponsiveContainer hook caused an infinite render loop because the wrapper had no stable width in non-mobile mode — it shrank to content (~48px), triggering breakpoint: "mobile" which applied width: 100% (~900px), flipping back to "desktop", and repeating endlessly.
  • Added value comparison to useResponsiveContainer: setSize now uses a functional updater that returns the previous state when width/height haven't changed, preventing unnecessary re-renders for all consumers of the hook.
  • Updated ImageBlock CSS for proper flex sizing: Replaced the unstable content-sized width with flex: 1 1 0; min-width: 0; and max-width: 100% on the image, so the wrapper fills its parent consistently without depending on breakpoint state.

Test plan

  • Verify ImageBlock renders without flashing on the Media tab at /chat
  • Switch between tabs (Overview → Media) and confirm no layout flash
  • Verify two ImageBlocks in a row Stack render side by side
  • Confirm ImageBlock still renders correctly as a standalone element
  • Check that other components using useResponsiveContainer are unaffected

Made with Cursor

…l safe on useResponsiveContainer and fixing style of the image block to fix height made the render loop stop on react renderer
@vercel

vercel Bot commented Mar 9, 2026

Copy link
Copy Markdown

@ankit-thesys is attempting to deploy a commit to the thesys-devs Team on Vercel.

A member of the Team first needs to authorize it.

@ankit-thesys
ankit-thesys merged commit 6d2e716 into thesysdev:main Mar 9, 2026
1 of 2 checks passed
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.

2 participants