5) Master Project: React Router and Routing Flashcards

1
Q

react router mimics ___.

A

url functionality

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is the most supported/popular react router library?

A

React Router DOM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What file does the import statement for BrowserRouter component go in? what is that statement?

A

index.js

import { BrowserRouter } from ‘react-router-dom’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What do you do with the Browser Router component once it has been imported?

A

wrapping around the app component in the index.js file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the three main attributes of the Router component?

A
  • exact: whether the path has to match exactly, default value is true
  • path: the path (url) that will be trigger to rendering the component
  • component: the component that we want the route to render
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the switch component used for?

A

wraps around route components and only renders the first one that matches

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What two main components will we be using from the routing library?

A

Switch and Route

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What 3 props get passed into the component identified in a router component?

A

history

location

match

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is the match prop useful for?

A

accessing dynamically chaging data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What react-router-DOM component replaces the a-tag? what are its attributes? what is the drawback?

A

Link

to=’url’

not dynamic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the dynamic version of using the Link component?

A

using the history prop in an event triggered call back function in a regular component (like a button):

onClick={() => props.history.push(‘/topics’)}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The match prop allows our components to build out …

A

a nested route structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is prop tunneling and why is it an issue?

A

sending props through child components, the components in the middle wont need the props.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a higher order component?

A

a function that takes a component as an argument and returns a modified component.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how do you use the withRouter() function on a component? what features does this give that component?

A

in the export statement wrap the component with the function.

gives us the history property

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is a shortcut for passing props into a component when the keys and value variables have the same name? [CODE ANSWER]

A