Skip to content

Instantly share code, notes, and snippets.

@lejonmanen
Last active February 29, 2024 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lejonmanen/21808731addb46912055e194ff1d8727 to your computer and use it in GitHub Desktop.
Save lejonmanen/21808731addb46912055e194ff1d8727 to your computer and use it in GitHub Desktop.
React components
// A component is a function that returns JSX
const Aaa = () => (
<div>
You can do any JSX in here
</div>
)
// Remember to export the component
// Most people have one component per file and use export default
export default Aaa
// Import any components you need here
import Aaa from '/Aaa.jsx'
import Fancy from './Fancy.jsx'
// Use the components inside the JSX, as many times you like
const App = () => {
return (
<main>
<Aaa />
<Aaa />
<Fancy item={'hello'} />
</main>
)
}
const Fancy = (props) => {
const { item } = props
return (
<div className="fancy">
{item}
</div>
)
}
export default Fancy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment