0
0
Remixframework~10 mins

Creating routes in Remix - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a route file named index.jsx that exports a default component.

Remix
export default function [1]() {
  return <h1>Home Page</h1>;
}
Drag options to blanks, or click blank then click option'
AIndex
BApp
CHomePage
DRoute
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name that is not descriptive or confusing.
Not exporting a default function.
2fill in blank
medium

Complete the code to import the Link component from Remix for navigation.

Remix
import { [1] } from "@remix-run/react";
Drag options to blanks, or click blank then click option'
ARoute
BRouter
CLink
DNavLink
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Route or Router instead of Link.
Forgetting to import from @remix-run/react.
3fill in blank
hard

Fix the error in the route loader function to return JSON data correctly.

Remix
import { json } from "@remix-run/node";

export async function loader() {
  const data = { message: "Hello" };
  return [1](data);
}
Drag options to blanks, or click blank then click option'
Aresponse
Bsend
CreturnData
Djson
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to return raw objects without wrapping in json.
Using undefined functions like response or send.
4fill in blank
hard

Fill both blanks to create a nested route file that exports a default component and a loader function.

Remix
import { json } from "@remix-run/node";

export async function [1]() {
  return [2]({ greeting: "Hi" });
}

export default function Greeting() {
  return <h2>Greeting Route</h2>;
}
Drag options to blanks, or click blank then click option'
Aloader
Bjson
Caction
Dfetch
Attempts:
3 left
💡 Hint
Common Mistakes
Naming the loader function incorrectly.
Not wrapping the returned data with json.
5fill in blank
hard

Fill all three blanks to create a route component that uses the loader data with the useLoaderData hook.

Remix
import { json } from "@remix-run/node";
import { [1] } from "@remix-run/react";

export async function loader() {
  return [2]({ user: "Alice" });
}

export default function User() {
  const data = [3]();
  return <p>User: {data.user}</p>;
}
Drag options to blanks, or click blank then click option'
AuseLoaderData
Bjson
DuseData
Attempts:
3 left
💡 Hint
Common Mistakes
Importing or calling the wrong hook.
Not wrapping loader return data with json.
Forgetting to call the hook as a function.