@@ -52,7 +52,7 @@ import { TbZoom } from "react-icons/tb";
5252import { GrRedo , GrUndo } from "react-icons/gr" ;
5353import { AiOutlineHome } from "react-icons/ai" ;
5454import { BiCopy } from "react-icons/bi" ;
55- import { redirect } from "next/navigation" ;
55+ import { useRouter } from "next/navigation" ;
5656import { useAppDispatch , useAppSelector } from "@/lib/hooks/redux" ;
5757import { setUser , setActiveRoom } from "@/lib/features/meetdraw/appSlice" ;
5858import { useWebSocket } from "@/lib/hooks/websocket" ;
@@ -84,6 +84,7 @@ const Canvas = ({ roomId, token }: { roomId: string; token: string }) => {
8484 const [ showChatBar , setShowChatBar ] = useState ( false ) ;
8585 const canvasRef = useRef < HTMLCanvasElement > ( null ) ;
8686 const [ isClient , setIsClient ] = useState ( false ) ;
87+ const router = useRouter ( ) ;
8788 const { socket, isLoading, isError } = useWebSocket (
8889 `${ process . env . NEXT_PUBLIC_WS_URL } ?token=${ token } `
8990 ) ;
@@ -178,7 +179,7 @@ const Canvas = ({ roomId, token }: { roomId: string; token: string }) => {
178179
179180 useEffect ( ( ) => {
180181 if ( ! token ) {
181- redirect ( "/signin" ) ;
182+ router . replace ( "/signin" ) ;
182183 }
183184
184185 if ( ! user ) {
@@ -1580,7 +1581,7 @@ const Canvas = ({ roomId, token }: { roomId: string; token: string }) => {
15801581 className = { `bg-transparent relative p-2 hover:bg-green-600/20 cursor-pointer` }
15811582 onClick = { ( ) => {
15821583 closeSocket ( ) ;
1583- redirect ( "/home" ) ;
1584+ router . replace ( "/home" ) ;
15841585 } }
15851586 >
15861587 < AiOutlineHome className = "text-white" size = "18" />
0 commit comments