+ Clearly identifies the cause and provides concise, safe cleanup code.
- The fallback key may collide, and messages are not reset on room changes.
a Code Review Specialist. You are an experienced software developer with a keen eye for detail and a deep understanding of coding standards and best p
| Category | Development › Coding |
|---|---|
| Tags | ReviewingAnalyzingDeveloperCode |
Act as a Code Review Specialist. You are an experienced software developer with a keen eye for detail and a deep understanding of coding standards and best practices.\n\nYour task is to review the code provided for quality, adherence to standards, and optimization potential.\n\nYou will:\n- Evaluate the code for compliance with industry standards and best practices.\n- Identify potential areas for optimization and suggest improvements.\n- Check for logical errors, bugs, and potential security vulnerabilities.\n- Provide constructive feedback to the code authors.\n\nRules:\n- Be objective and unbiased in your review.\n- Focus on both functional and non-functional aspects of the code.\n- Maintain a professional and respectful tone in all feedback.
This developer role prompt is for reviewing code quality. It asks for both functional and non-functional review while maintaining a professional and respectful tone.
ChatGPT has the best balance of accuracy and length. Gemini is broader but verbose and occasionally overstated, while [C] was not provided.
+ Clearly identifies the cause and provides concise, safe cleanup code.
- The fallback key may collide, and messages are not reset on room changes.
+ Broadly reviews room changes, parsing, keys, and socket handling.
- It ignores React-version differences and overstates parsing as a component crash.
| Criterion | ChatGPT | Gemini | Leader |
|---|---|---|---|
| Instruction following | 9 | 9 | Tie |
| Accuracy | 9 | 7 | ChatGPT +29% |
| Specificity | 9 | 9 | Tie |
| Structure | 9 | 8 | ChatGPT +13% |
| Right length | 9 | 6 | ChatGPT +50% |
Scored 1–10 by gpt-5.6-sol with model names hidden (2026-09-24). This is an AI review, not a measurement.
We gave three models the same input and copied their answers unedited. Each ran in its CLI (an agent harness), and answers in the ChatGPT or Claude apps or on the web may differ. Outputs are in Korean.
[Pasted material]
React 컴포넌트인데 다른 페이지로 이동했다가 돌아오면 콘솔에 경고가 쌓입니다. 원인 좀 봐주세요.
```jsx
function ChatRoom({ roomId }) {
const [messages, setMessages] = useState([]);
useEffect(() => {
const socket = new WebSocket(`wss://chat.example.com/${roomId}`);
socket.onmessage = (e) => {
setMessages(prev => [...prev, JSON.parse(e.data)]);
};
}, [roomId]);
return <ul>{messages.map((m, i) => <li key={i}>{m.text}</li>)}</ul>;
}
```원인은 useEffect에서 생성한 WebSocket을 정리하지 않는 것입니다. 페이지를 떠나도 연결과 onmessage 핸들러가 남아 있어, 다시 돌아오면 소켓이 중복 생성되고 이전 연결이 setMessages를 계속 호출할 수 있습니다.
import { useEffect, useState } from "react";
function ChatRoom({ roomId }) {
const [messages, setMessages] = useState([]);
useEffect(() => {
const socket = new WebSocket(
`wss://chat.example.com/${encodeURIComponent(roomId)}`
);
let active = true;
socket.onmessage = (event) => {
if (!active) return;
try {
const message = JSON.parse(event.data);
setMessages((prev) => [...prev, message]);
} catch {
console.error("잘못된 WebSocket 메시지:", event.data);
}
};
socket.onerror = (error) => {
console.error("WebSocket 오류:", error);
};
return () => {
active = false;
socket.onmessage = null;
socket.onerror = null;
if (
socket.readyState === WebSocket.OPEN ||
socket.readyState === WebSocket.CONNECTING
) {
socket.close();
}
};
}, [roomId]);
return (
<ul>
{messages.map((message) => (
<li key={message.id ?? `${message.timestamp}-${message.text}`}>
{message.text}
</li>
))}
</ul>
);
}
추가로 확인할 사항은 다음과 같습니다.
key={i}는 메시지 삽입·삭제 시 잘못된 DOM 재사용을 유발할 수 있으므로 서버 메시지의 고유 ID를 사용하세요.JSON.parse는 외부 데이터이므로 예외 처리가 필요합니다.| 12-Month AI and Computer Vision Roadmap for Defense Applications | |
| 2046 Puzzle Game Challenge | |
| 21st.dev component prompt | |
| 3D FACTORY | |
| 3D FPS Game |