0
0
Astroframework~20 mins

client:load directive in Astro - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Astro Client Load Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when using client:load in Astro?

Consider an Astro component that uses client:load to load a React component. What is the behavior of the React component in the browser?

Astro
---
import MyReactComponent from '../components/MyReactComponent.jsx';
---
<MyReactComponent client:load />
AThe React component is rendered on the server and hydrated immediately before the page loads.
BThe React component is rendered only after the page HTML is fully loaded and hydrated on the client side.
CThe React component is never rendered because <code>client:load</code> disables client-side rendering.
DThe React component is rendered immediately on the server and sent as static HTML without hydration.
Attempts:
2 left
💡 Hint

Think about when client:load triggers the loading of client-side JavaScript.

📝 Syntax
intermediate
1:30remaining
Identify the correct syntax to use client:load in Astro

Which of the following is the correct way to apply the client:load directive to a component in Astro?

A<MyComponent client:load />
B<MyComponent clientLoad />
C<MyComponent client-load />
D<MyComponent client_load />
Attempts:
2 left
💡 Hint

Astro directives use colon syntax, not camelCase or underscores.

🔧 Debug
advanced
2:30remaining
Why does this Astro component with client:load fail to hydrate?

Given this Astro code, the React component does not hydrate on the client. What is the most likely cause?

Astro
---
import ReactComponent from '../components/ReactComponent.jsx';
---
<ReactComponent client:load></ReactComponent>
AAstro requires wrapping React components in <code>&lt;Fragment&gt;</code> for hydration.
BThe <code>client:load</code> directive is only for Vue components, not React.
CThe component must use <code>client:visible</code> instead of <code>client:load</code> to hydrate.
DThe React component file is missing a default export, so Astro cannot import it correctly.
Attempts:
2 left
💡 Hint

Check the React component export style.

state_output
advanced
2:30remaining
What is the state behavior of a React component loaded with client:load in Astro?

Consider a React component with internal state rendered using client:load in Astro. When does the state initialize and how does it behave?

Astro
---
import Counter from '../components/Counter.jsx';
---
<Counter client:load />
AThe state initializes only after the component is hydrated on the client, starting at 0 and updating on clicks.
BThe state is shared between server and client, so updates persist across page reloads.
CThe state initializes on the server and is sent as static HTML with the count value.
DThe state never initializes because <code>client:load</code> disables React hooks.
Attempts:
2 left
💡 Hint

Think about when React hooks run in client-side rendering.

🧠 Conceptual
expert
3:00remaining
Why choose client:load over client:idle or client:visible in Astro?

Which reason best explains when client:load is the preferred directive for loading client-side components in Astro?

A<code>client:load</code> delays loading until the user scrolls near the component, improving performance for offscreen elements.
B<code>client:load</code> waits until the browser is idle before loading, minimizing impact on page load speed.
C<code>client:load</code> ensures the component loads immediately after the page finishes loading, useful for components that must be interactive right away but don't block initial HTML rendering.
D<code>client:load</code> pre-renders the component on the server and disables client-side hydration.
Attempts:
2 left
💡 Hint

Consider the timing of when the component becomes interactive.