Closed IsoPhoenix closed 1 year ago
General flow of using react-router
for the forum page:
TeacherView.tsx
and StudentView.tsx
, add a new /forum
route with a /:postID
child route. /forum
route should display a component ForumView.tsx
that displays all created posts and has option to create a new post. Should contain components:
CreatePostModal
: Inputs for creating a new postForumPostCard
: Card that lists a specific forum post. Clicking on it should utilize a Link
to navigate to /forum/:postID
corresponding to the post./forum/:postID
should correspond to a component ForumPost.tsx
that displays the information in the post. Use useParams()
to get the post ID from the URL. // TeacherView.tsx
<Routes>
...
<Route path='forum' element={<ForumView />}>
<Route path=':postID/*' element={<ForumPost />} // the * includes any subroutes of the post
</Route>
</Routes>
Additional notes:
ForumView
to render child components (like posts) inside the overall forum view. Then ForumView
would contain the nagivation sidebar with categories./
path that uses a Navigate
to a ForumHome
component.
// TeacherView.tsx
<Routes>
...
<Route path='forum/*' element={<ForumView />} />
</Routes>
// ForumView.tsx ... // Layout and navigation elements go here
...
// ForumHome.tsx // Contains the master list of posts and create post functionality (with CreatePostModal and ForumPostCard components as described above)
// ForumPost.tsx // Same as above
Forum: Create + View Discussion
Overview
Functionality to create discussion threads and leave comments
Resources
react-query-firebase
documentationFrontend
src/routes/general
calledForumView.tsx
that can be accessed from bothStudentView.tsx
andTeacherView.tsx
Backend
react-query-firebase
to write all your database operations (queries and mutations). You can write queries in the files in which they are used, but I advise factoring mutations out tomutations.js
.useDatabaseSnapshot
hook from React Query Firebase.