w7d4 - react router Flashcards

1
Q

What props can you pass into a Route?

A

path
component
exact

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

What’s the purpose of a Route?

A

A Route is used to wrap another component, causing that component to only be rendered if a certain URL is matched.

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

What does the exact prop do when passed in to Route?

A

The component will only render if that route and that route exactly matches (no params in the url, no variance from the path prop period).

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

What’s the parent router component called?

A

HashRouter

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

What are child route components called?

A

Router

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

What props does a Router pass to its child component?

A

location
match
history

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

What keys does the match prop contain?

A

isExact
url
path
params

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

What methods does the history prop contain? What do they do?

A

push - adds a new URL to the end of the history stack

replace - replaces the current URL on the history stack, so the back button won’t take you to it.

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

From within a Routeful component, how do we get user_id from the path?

A

this.props.match.params.userId

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

How do you use a Link component?

A

<link></link>

Users</Users>

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

Optional prop to pass to Link?

A

onClick

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

Difference between a NavLink and regular Link?

A

logic that automatically chooses a secondary activeClassName CSS class when its route is active.

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

How do you select one Route out of many to render when many Routes match the same path?

A

Wrap the routes in a Switch. First one that matches will be rendered.

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

What’s the value of using a Switch?

A

It will select one Route out of many to render when many Routes match the same path.

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

How do we redirect a user?

A

Redirect component

use the to=”/new_url” prop

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