Framework Flashcards

(40 cards)

1
Q

Where are routes defined in React Router v7 framework mode?

A

In app/routes.ts

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

What are the two essential elements needed for each route definition?

A

URL pattern and file path to route module

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

How is type safety enforced in route configurations?

A

Using TypeScript with satisfies RouteConfig

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

What function creates a standard route in React Router v7?

A

route(path, modulePath)

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

What function creates a default route for a parent URL?

A

index(modulePath)

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

What function creates a wrapper without adding a URL segment?

A

layout(modulePath, children)

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

How do you add a path prefix to a group of routes?

A

prefix(path, routes)

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

How are child routes rendered within parent routes?

A

Through the <Outlet/> component in the parent

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

What special file are all routes nested inside?

A

app/root.tsx

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

What URL structure does route nesting create?

A

Hierarchical URL structure (e.g., /dashboard/settings)

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

What is an index route?

A

Default child route rendered at the parent’s URL path

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

How do you define an index route?

A

index("./home.tsx")

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

What is a layout route?

A

A route that provides UI structure without adding a URL segment

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

How do you define a dynamic segment in a route path?

A

With a colon prefix (:) - route("teams/:teamId")

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

How do you define an optional segment in a route path?

A

With a question mark suffix (?) - route(":lang?/categories")

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

What is a splat/catchall route?

A

A route that matches the remaining URL with /* - route("files/*")

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

What are the three main capabilities of route modules?

A

Code-splitting, data loading, and error handling

18
Q

What is the purpose of the default export in a route module?

A

Component rendered when the route matches

19
Q

What is the difference between loader and clientLoader?

A

loader runs on server, clientLoader runs only in browser

20
Q

What is the difference between action and clientAction?

A

action handles server-side mutations, clientAction handles browser-only mutations

21
Q

What component handles errors in a route module?

A

ErrorBoundary

22
Q

What component displays during client loading?

A

HydrateFallback

23
Q

What export controls when to refresh data?

A

shouldRevalidate

24
Q

What prop provides access to data from loader/clientLoader?

25
What prop provides access to data from action/clientAction?
`actionData`
26
What prop contains URL parameters from dynamic segments?
`params`
27
What prop provides all matches in the current route tree?
`matches`
28
How do you disable Server-Side Rendering (SSR) in React Router v7?
Set `ssr: false` in config
29
How do you define URLs for static pre-rendering?
Use `async prerender()` function returning URL array
30
How can you access server data in a clientLoader?
Use `serverLoader()` function
31
What component shows while clientLoader data is loading?
`HydrateFallback`
32
What are the benefits of combining `loader` and `clientLoader`?
Enables hybrid data strategies with both server and client data
33
What are the three ways to call actions in React Router v7?
Form-based (`
`), imperative (`useSubmit()`), and fetcher-based (`useFetcher()`)
34
Which method of calling actions does not cause navigation?
Fetcher-based (`useFetcher()`)
35
What component provides navigation with active states?
``
36
How do you perform programmatic navigation in loaders/actions?
`redirect("/path")`
37
What hook enables programmatic navigation in components?
`useNavigate()`
38
What hook exposes global navigation state?
`useNavigation()`
39
How do you track the state of an independent form submission?
With `fetcher.state`
40
How can you implement optimistic UI updates?
Use `fetcher.formData` to predict future state before server response