- What is a
BrowserRouter
component? What is the purpose of it? - What is the
path
property in aroute
? - What is a
param
and how can we pass them? - What is
Link
and why does it have ato
attribute?
-
-
Save AllanSaleh/8ff7f3e2c21549d110ec02be999cf1c0 to your computer and use it in GitHub Desktop.
ghost
commented
Dec 9, 2022
- It is a router implementation that uses the HTML5 history API (pushstate, replacestate, and popstate events) to keep your UI in sync with the URL. It is the parent component used to store all other components.
- The path property describes the URL this route will handle, like branches.
- It is a hook (useParams) We can use the dynamic params as path matched with URL
- It allows us to navigate around our application. 'To' is a location descriptor.
1- BrowserRouter: It comes with React Router. It is used for to hold current location as clean URLs and it provides navigation between URLs. It has Routes and Route inside itself.
2 - "path" property in a route: There can be multiple routes in an application so each route has a path. Paths represents specific URLs. If users type a specific URL into the browser and if any path of routes matches with this URL, users are redirected to the route that has the matched path.
3- param: param means parameters. If we want to pass params and also be dynamic, useParams hook can be used.
4- Link: It provides to navigate to different routes defined in the application. It can be consider like "a" tag in html. "to" is like "href" in html so "to" shows us where will we go when clicking or selecting this link.