#123 fix: 코드 에디터 버그 해결#124
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit릴리스 노트
개요
변경사항할당 변경 시 편집기 상태 동기화
예상 코드 리뷰 난이도🎯 1 (Trivial) | ⏱️ ~3분 연관 이슈
추천 레이블
추천 리뷰어
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/pages/submit-assignment/AssignmentSubmitPage.tsx`:
- Around line 35-37: The effect in AssignmentSubmitPage (useEffect that calls
setCurrentCodeId(initialCodeId)) is missing initialCodeId in its dependency
array so changes to initialCodeId (from location.state) won't update
currentCodeId; update the dependency array to include initialCodeId (in addition
to assignmentId) so the effect re-runs when either assignmentId or initialCodeId
changes, ensuring setCurrentCodeId(initialCodeId) stays synchronized with the
incoming state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4a5de0d6-b9b0-415f-b3fe-7730d1a5ac9b
📒 Files selected for processing (1)
src/pages/submit-assignment/AssignmentSubmitPage.tsx
| useEffect(() => { | ||
| setCurrentCodeId(initialCodeId); | ||
| }, [assignmentId]); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n src/pages/submit-assignment/AssignmentSubmitPage.tsx | head -60Repository: 2025-snowCode/snowCode-Client
Length of output: 2842
useEffect 의존성 누락으로 initialCodeId 변경이 반영되지 않을 수 있어요.
initialCodeId는 location.state에서 추출되어 렌더링마다 새로 평가되는데, effect 내부에서 사용 중인 initialCodeId가 의존성 배열에 없습니다. 같은 assignmentId에서 다른 codeId를 가진 state로 이동할 때 currentCodeId가 동기화되지 않을 수 있습니다.
✅ 제안 수정
useEffect(() => {
setCurrentCodeId(initialCodeId);
- }, [assignmentId]);
+ }, [assignmentId, initialCodeId]);React 공식 문서의 useEffect 의존성 배열 가이드에서 "effect가 사용하는 모든 반응형 값(props, state, 파생 값)을 의존성에 포함"해야 한다는 규칙을 참고해 주세요.
🧰 Tools
🪛 GitHub Check: build-and-deploy
[warning] 37-37:
React Hook useEffect has a missing dependency: 'initialCodeId'. Either include it or remove the dependency array
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/pages/submit-assignment/AssignmentSubmitPage.tsx` around lines 35 - 37,
The effect in AssignmentSubmitPage (useEffect that calls
setCurrentCodeId(initialCodeId)) is missing initialCodeId in its dependency
array so changes to initialCodeId (from location.state) won't update
currentCodeId; update the dependency array to include initialCodeId (in addition
to assignmentId) so the effect re-runs when either assignmentId or initialCodeId
changes, ensuring setCurrentCodeId(initialCodeId) stays synchronized with the
incoming state.
⚙️ Related ISSUE Number
Related #123
📄 Work Description
문제 변경 시
currentCodeId초기화📷 Screenshot
💬 To Reviewers
🔗 Reference