Open DomVinyard opened 1 year ago
This is a useful resource for learning about React Router: https://www.youtube.com/watch?v=Ul3y1LXxzdU
Should clicking the <a>
tag on the homepage take the user to the Topic Page? and is the Topic Card to be rendered within topic page?
Whats the purpose of the colon before topic please e.g. "/:topic"
After implementing the AppRouter.js, should we delete the App.js ? we have chosen to have the AppRouter file in the index.js file where the App.js would usually go:
import AppRouter from "./AppRouter";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<AppRouter />
</React.StrictMode>
);
reportWebVitals();
@bp289 We've deleted it, but I'm sure it's no harm
@mdapim This allows us to use the useParams() feature of react-router-dom. Remember in Flask we were able to use
@app.route('/home/<id>')
? Where ID was a variable we could set? Well, the colon acts just like the <>. We can interact with it using useParams() e.g.
const {id} = useParams()
inside the element
Will there be actually 3 different routes, i.e.
"/" : HomePage
"/topic/" : Main topics page
"topic/:topic" : Particular Topic of Interest Page
I'd argue it should be like this to allow navigation between the home and topics page to be more streamlined for the user. If I was on a particular topic, then navigated to home, and then back to topic, I wouldn't want to see the last topic I saw using the navigation, but instead perhaps a list of recently added topics.
@Ademsk1 I thought that as well so didn't know whether to get rid of initial app.js file as that could be the topics page before particular topic of interest
Will there be actually 3 different routes, i.e.
It would be a good idea for a website with multiple features, but in this case let's keep the URL super simple like:
@DomVinyard When using useParams() should we be taking into account invalid requests such as below yet, or would that be a separate ticket please?
We need to implement React Router in our React application to allow for navigation between different pages. We want to create two initial routes:
Tasks:
http://localhost:4000/topics
we should instead fetch data fromhttp://localhost:4000/topic/${topic_name}
. The topic name should be fetched from the url.Acceptance Criteria: