Recall & Review
beginner
What is the purpose of exporting a component in React?
Exporting a component allows it to be used in other files by making it available outside its own file.
Click to reveal answer
beginner
What is the difference between a default export and a named export?
A default export lets you export one main thing from a file and import it without curly braces. Named exports allow exporting multiple things and require curly braces when importing.Click to reveal answer
beginner
How do you import a default exported component named <code>Header</code> from a file <code>Header.js</code>?Use <code>import Header from './Header';</code> to import the default exported component.Click to reveal answer
beginner
How do you import a named exported component called <code>Footer</code> from <code>Footer.js</code>?Use <code>import { Footer } from './Footer';</code> with curly braces to import a named export.Click to reveal answer
intermediate
Why might you choose named exports over default exports in React components?
Named exports help keep imports clear and allow exporting multiple components from one file, making code easier to manage and avoid naming conflicts.
Click to reveal answer
Which syntax correctly exports a React component as the default export?
✗ Incorrect
The 'export default' syntax exports the component as the default export.
How do you import a named export called
Button from a file?✗ Incorrect
Named exports must be imported with curly braces.
What happens if you try to import a default export using curly braces?
✗ Incorrect
Default exports must be imported without curly braces; using them causes errors.
Which statement is true about named exports?
✗ Incorrect
Named exports allow multiple exports from a single file.
If a file exports a component as default, how do you rename it on import?
✗ Incorrect
Default exports can be imported with any name you choose without curly braces.
Explain how to export and import a React component using default export.
Think about how you share one main component from a file.
You got /3 concepts.
Describe the difference between named exports and default exports in React components.
Consider how you might organize many components in one file.
You got /3 concepts.