0
0
Remixframework~20 mins

Progressive enhancement in Remix - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Remix Progressive Enhancement Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
How does Remix handle progressive enhancement with forms?

Consider a Remix form component that uses the Form component from Remix. What happens when JavaScript is disabled in the browser?

Remix
import { Form } from '@remix-run/react';

export default function ContactForm() {
  return (
    <Form method="post">
      <label htmlFor="email">Email:</label>
      <input id="email" name="email" type="email" required />
      <button type="submit">Send</button>
    </Form>
  );
}
AThe form shows an error message because Remix requires client-side validation only.
BThe form submits via a full page reload and the server handles the request normally.
CThe form submits via AJAX automatically without any server reload.
DThe form does not submit at all because JavaScript is required for submission.
Attempts:
2 left
💡 Hint

Think about how HTML forms work by default and how Remix builds on top of that.

state_output
intermediate
2:00remaining
What is the output when using Remix loader with progressive enhancement?

Given a Remix route with a loader that fetches data, what will the user see if JavaScript is disabled?

Remix
import { useLoaderData } from '@remix-run/react';

export async function loader() {
  return { message: 'Hello from server' };
}

export default function Greeting() {
  const data = useLoaderData();
  return <h1>{data.message}</h1>;
}
A<h1>Hello from server</h1> rendered as static HTML on page load.
BAn empty page because useLoaderData requires JavaScript to fetch data.
CA loading spinner indefinitely because data fetching is client-side only.
DA JavaScript error because loader is not supported without client scripts.
Attempts:
2 left
💡 Hint

Remember that Remix loaders run on the server before the page is sent.

🔧 Debug
advanced
2:00remaining
Why does this Remix form lack progressive enhancement?

Review the following Remix form code. Why does it lack progressive enhancement?

Remix
import { Form } from '@remix-run/react';

export default function MyForm() {
  return (
    <form method="post">
      <input name="name" />
      <button type="submit">Submit</button>
    </form>
  );
}
ABecause the form method is missing, so the browser does not know how to submit.
BBecause the input is missing a type attribute, the form cannot submit.
CBecause the button type is incorrect; it should be type="button".
DBecause the code uses a plain <form> instead of Remix's <Form> component, progressive enhancement is lost.
Attempts:
2 left
💡 Hint

Consider how Remix's Form component differs from a plain HTML form.

📝 Syntax
advanced
2:00remaining
Which Remix loader syntax correctly supports progressive enhancement?

Choose the correct Remix loader function syntax that ensures data is available for server rendering and progressive enhancement.

A
import { json } from '@remix-run/node';

export async function loader() {
  return json({ user: 'Alice' });
}
B
export function loader() {
  fetch('/api/user').then(res =&gt; res.json());
}
C
export async function loader() {
  return { user: await fetch('/api/user') };
}
D
export async function loader() {
  return await fetch('/api/user').json();
}
Attempts:
2 left
💡 Hint

Remember that Remix loaders must return a Response or data wrapped with json().

🧠 Conceptual
expert
3:00remaining
What is the key benefit of Remix's progressive enhancement approach compared to SPA frameworks?

Why does Remix emphasize progressive enhancement in its design compared to typical single-page application (SPA) frameworks?

AIt forces all rendering to happen on the client, reducing server load.
BIt requires developers to write separate code for server and client rendering.
CIt ensures the app works fully with or without JavaScript, improving accessibility and SEO.
DIt disables client-side navigation to simplify the app architecture.
Attempts:
2 left
💡 Hint

Think about what progressive enhancement means for users with limited browser capabilities.