Framework Flashcards

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?

A

loaderData

25
Q

What prop provides access to data from action/clientAction?

A

actionData

26
Q

What prop contains URL parameters from dynamic segments?

27
Q

What prop provides all matches in the current route tree?

28
Q

How do you disable Server-Side Rendering (SSR) in React Router v7?

A

Set ssr: false in config

29
Q

How do you define URLs for static pre-rendering?

A

Use async prerender() function returning URL array

30
Q

How can you access server data in a clientLoader?

A

Use serverLoader() function

31
Q

What component shows while clientLoader data is loading?

A

HydrateFallback

32
Q

What are the benefits of combining loader and clientLoader?

A

Enables hybrid data strategies with both server and client data

33
Q

What are the three ways to call actions in React Router v7?

A

Form-based (<Form>), imperative (useSubmit()), and fetcher-based (useFetcher())

34
Q

Which method of calling actions does not cause navigation?

A

Fetcher-based (useFetcher())

35
Q

What component provides navigation with active states?

A

<NavLink to="/path">

36
Q

How do you perform programmatic navigation in loaders/actions?

A

redirect("/path")

37
Q

What hook enables programmatic navigation in components?

A

useNavigate()

38
Q

What hook exposes global navigation state?

A

useNavigation()

39
Q

How do you track the state of an independent form submission?

A

With fetcher.state

40
Q

How can you implement optimistic UI updates?

A

Use fetcher.formData to predict future state before server response