Recall & Review
beginner
What is the main purpose of using React components inside an Astro project?
React components let you add interactive UI parts inside Astro, which mainly builds static sites. This way, you get the best of both: fast static pages and dynamic React features.Click to reveal answer
beginner
How do you import a React component into an Astro file?Use the syntax: <code>import MyComponent from './MyComponent.jsx';</code> at the top of your Astro file. Then you can use <code><MyComponent /></code> inside your Astro template.Click to reveal answer
intermediate
What is the role of the
client:load directive when using React components in Astro?The
client:load directive tells Astro to load and run the React component only on the browser after the page loads. This makes the component interactive without slowing down the initial page load.Click to reveal answer
intermediate
Can you explain the difference between
client:load and client:idle in Astro React components?client:load loads the React component as soon as the page loads. client:idle waits until the browser is idle before loading the component, improving performance by delaying less important scripts.Click to reveal answer
beginner
Why is it important to use React components only where interactivity is needed in Astro?
Because React components add JavaScript to the page, using them only when needed keeps the site fast and lightweight. Astro’s strength is static content, so limiting React helps maintain speed and good user experience.
Click to reveal answer
How do you make a React component interactive in Astro?
✗ Incorrect
Adding
client:load tells Astro to load the React component on the client side, making it interactive.Where do you write the import statement for a React component in an Astro file?
✗ Incorrect
You import React components at the top of the Astro file using JavaScript import syntax.
What happens if you don't add any client directive to a React component in Astro?
✗ Incorrect
Without a client directive, Astro renders the React component as static HTML without JavaScript interactivity.
Which client directive delays loading a React component until the browser is idle?
✗ Incorrect
client:idle waits for the browser to be idle before loading the component, improving performance.Why might you choose to use React components inside Astro instead of pure Astro components?
✗ Incorrect
React components are used inside Astro to add interactivity that static Astro components alone cannot provide.
Describe the steps to add a React component to an Astro page and make it interactive.
Think about import, usage, and client directives.
You got /3 concepts.
Explain why Astro uses client directives like client:load or client:idle when working with React components.
Consider how loading timing affects user experience.
You got /4 concepts.