Last active
February 29, 2024 16:37
-
-
Save lejonmanen/21808731addb46912055e194ff1d8727 to your computer and use it in GitHub Desktop.
React components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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