0
0
Astroframework~10 mins

React components in Astro - Interactive Code Practice

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

Complete the code to import a React component into an Astro file.

Astro
import MyComponent from './components/MyComponent.[1]';
Drag options to blanks, or click blank then click option'
Ajsx
Btsx
Cjs
Dastro
Attempts:
3 left
💡 Hint
Common Mistakes
Using .astro extension instead of .jsx
Using .tsx when the component is not TypeScript
Using .js which might not support JSX syntax
2fill in blank
medium

Complete the code to render a React component inside an Astro file.

Astro
<MyComponent [1] />
Drag options to blanks, or click blank then click option'
Aclient:load
Bclient:idle
Crender
Dclient:only
Attempts:
3 left
💡 Hint
Common Mistakes
Using render attribute which is invalid
Using client:only which loads only on client but delays hydration
Using client:idle which delays loading
3fill in blank
hard

Fix the error in the React component usage by completing the client directive.

Astro
<MyComponent [1] />
Drag options to blanks, or click blank then click option'
Aclient:visible
Bclient:load
Cclient:media
Dclient:only
Attempts:
3 left
💡 Hint
Common Mistakes
Using client:load which hydrates immediately but is not React-specific
Using client:visible which hydrates on visibility
Using client:media which hydrates based on media queries
4fill in blank
hard

Fill both blanks to correctly import and use a React component with client-only hydration.

Astro
import [1] from './components/Button.jsx';

<[2] client:only="react" />
Drag options to blanks, or click blank then click option'
AButton
BButtonComponent
DBtn
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching import and usage names
Forgetting the client:only directive
Using incorrect component names
5fill in blank
hard

Fill all three blanks to create a React component in Astro that passes props and uses client-only hydration.

Astro
import [1] from './components/Card.jsx';

<[2] title=[3] client:only="react" />
Drag options to blanks, or click blank then click option'
ACard
B"Welcome"
D"Hello"
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatched component names
Passing props without quotes
Omitting client:only directive