Skip to content

fix: remove circular useEffect deps in PreviewFrame and add toggle tests - #6

Merged
alinepuresv merged 1 commit into
mainfrom
claude/issue-5-20260227-0809
Feb 27, 2026
Merged

fix: remove circular useEffect deps in PreviewFrame and add toggle tests#6
alinepuresv merged 1 commit into
mainfrom
claude/issue-5-20260227-0809

Conversation

@alinepuresv

Copy link
Copy Markdown
Owner

Fixes #5

  • Replace useState(true) for isFirstLoad with useRef(true) in PreviewFrame to avoid re-render cascades
  • Remove error and isFirstLoad from the useEffect dependency array; both were being set inside the effect, creating unnecessary re-render cycles on every file system change
  • Add toggle button tests in src/app/__tests__/main-content.test.tsx to verify Preview/Code switching works correctly

Generated with Claude Code

- Replace useState(true) for isFirstLoad with useRef(true) in PreviewFrame
  so that tracking first-load state does not trigger re-renders or re-run
  the effect when updated
- Remove `error` and `isFirstLoad` from the useEffect dependency array;
  both were being set *inside* the effect, creating unnecessary re-render
  cascades on every file system change
- Remove the now-redundant early `setError(null)` guard (the success path
  already calls setError(null) at its end)
- Add src/app/__tests__/main-content.test.tsx to verify the Preview/Code
  toggle buttons correctly switch views in both directions and multiple times

Co-authored-by: Alin Epure <alinepuresv@users.noreply.github.com>
@alinepuresv
alinepuresv merged commit d83fdf8 into main Feb 27, 2026
1 check 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.

Toggle buttons

1 participant