Skip to content

Commit 43f6a9a

Browse files
committed
fix(room): add toast to useEffect dependencies and rename shadowing variable
1 parent aa5d83a commit 43f6a9a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

frontend/src/pages/room/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,16 @@ export default function RoomPage() {
135135
// 如果房间不存在,清除用户状态并返回首页
136136
useEffect(() => {
137137
if (error && !isLoading && !room) {
138-
const user = useAuthStore.getState().user
139-
if (user?.currentRoomId === roomId) {
138+
const currentUser = useAuthStore.getState().user
139+
if (currentUser?.currentRoomId === roomId) {
140140
useAuthStore.setState({
141-
user: { ...user, currentRoomId: null }
141+
user: { ...currentUser, currentRoomId: null }
142142
})
143143
}
144144
toast('房间不存在或已关闭')
145145
navigate('/', { replace: true })
146146
}
147-
}, [error, isLoading, room, roomId, navigate])
147+
}, [error, isLoading, room, roomId, navigate, toast])
148148

149149
useEffect(() => {
150150
if (roomId && token && !connectedRef.current) {

0 commit comments

Comments
 (0)