Term
What React Router library and component should be used for applications, hosted in a browser environment? |
|
Definition
react-router-dom library and BrowserRouter component Example: import { BrowserRouter } from 'react-router-dom' |
|
|
Term
How many component types are there in React Router? |
|
Definition
3 types - router components, route matching components, and navigation components:
import { BrowserRouter, Route, Link } from 'react-router-dom' |
|
|
Term
When should be used and when ? |
|
Definition
You should use a if you have a server that responds to requests and a if you are using a static file server. |
|
|
Term
How is Route matching done? |
|
Definition
by comparing a 's path prop to the current location’s pathname. When a matches it will render its content and when it does not match, it will render null. A with no path will always match. |
|
|
Term
What is NavLink and what is it used for? |
|
Definition
The NavLink is a special type of Link that can style itself as “active” when its to prop matches the current location. |
|
|
Term
How to programmatically navigate/force navigation? |
|
Definition
You can render a . When a renders, it will navigate using its to prop. |
|
|