Component Import/Export in React
From the React Components & JSX cheat sheet · Component Essentials · verified Jul 2026
Component Import/Export
Organize components in separate files
javascript
// Button.js - Export component
function Button({ text, onClick }) {
return <button onClick={onClick}>{text}</button>
}
export default Button
// App.js - Import and use
import Button from './Button'
function App() {
return (
<div>
<h1>My App</h1>
<Button text="Click me" onClick={() => alert('Hi!')} />
</div>
)
}💡 One component per file is common practice
📌 Use default export for main component
⚡ Named exports for utility components
importexportmodules