Skip to content

Instantly share code, notes, and snippets.

@sunmeat
Created May 10, 2025 13:45
Show Gist options
  • Save sunmeat/4837f76e0be00fe97b1e0c734582ab08 to your computer and use it in GitHub Desktop.
Save sunmeat/4837f76e0be00fe97b1e0c734582ab08 to your computer and use it in GitHub Desktop.
component composition example
import React from 'react'
import './App.css'
function MyButton() {
return <button>Hello</button>
}
function BorderedButton() {
return (
<div className="bordered">
<MyButton />
</div>
);
}
export class MyHeader extends React.Component {
render() {
return <h1>Hello</h1>
}
}
function App() {
return (
<>
<MyButton/>
<MyHeader/>
<BorderedButton />
</>
)
}
export default App
/*
добавить в App.jsx:
.bordered {
border: 2px solid blue;
padding: 10px;
display: inline-block;
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment