Skip to content

Instantly share code, notes, and snippets.

@sunmeat
Last active August 26, 2025 07:43
Show Gist options
  • Select an option

  • Save sunmeat/4837f76e0be00fe97b1e0c734582ab08 to your computer and use it in GitHub Desktop.

Select an option

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