작성
·
502
0
다른분들의 질문들을 보면서 수정을 해보았지만 해결되지 않아 질문 올립니다.
-react-router-dom 버전으로 인해 swtch는 Routes로 바꾸었으며
worspace뒤에 *을 붙였습니다.
//App.ts
<Routes>
<Route path="/" element={<Navigate replace to="/login" />} />
<Route path="/login" element={<LogIn />} />
<Route path="/signup" element={<SignUp />} />
<Route path="/workspace/:workspace/*" element={<Workspace />} />
</Routes>
workspace.tsx 에서는 밑에 코드로 바꾸었습니다.
//Workspace.tsx
<Routes>
<Route path="channel/:channel" element={<Channel />} />
<Route path="dm/:id" element={<DirectMessage />} />
</Routes>
그리고 나서 login 은 잘 되고 쿠키도 잘 저장되지만
http://localhost:3090/workspace/sleact/channel/%EC%9D%BC%EB%B0%98 이 주소로 가면 아래 같은 에러가 뜨면서 창이 뜨지 않습니다. 어떤게 잘못된 걸까요 ㅠ
Cannot read properties of undefined (reading 'match')
useParams
alecture/./node_modules/react-router/esm/react-router.js:760:34 ChannelList
alecture/./components/ChannelList/index.tsx:40:75 renderWithHooks
alecture/./node_modules/react-dom/cjs/react-dom.development.js:14985:18 mountIndeterminateComponent
alecture/./node_modules/react-dom/cjs/react-dom.development.js:17811:13 beginWork
alecture/./node_modules/react-dom/cjs/react-dom.development.js:19049:16 HTMLUnknownElement.callCallback
alecture/./node_modules/react-dom/cjs/react-dom.development.js:3945:14 Object.invokeGuardedCallbackDev
alecture/./node_modules/react-dom/cjs/react-dom.development.js:3994:16 invokeGuardedCallback
alecture/./node_modules/react-dom/cjs/react-dom.development.js:4056:31 beginWork$1
alecture/./node_modules/react-dom/cjs/react-dom.development.js:23959:7 performUnitOfWork
alecture/./node_modules/react-dom/cjs/react-dom.development.js:22771:12
답변 2
0
0
Workspace 컴포넌트에 코드
<Route path="/:workspace/channel/:channel" element={<Channel />} />
<Route path="/:workspace/dm/:id" element={<DirectMessage />} />
이렇게 작성해보시겠어용??
말씀해주신대로 해보았지만 똑같은 에러가 뜹니다 .. app.js에는 workspace 맨뒤에 *은 찍은 상태로 했습니다..