Created
February 22, 2020 17:55
-
-
Save Toinne/e5f22c0a7319bd63a3ad09aa23867932 to your computer and use it in GitHub Desktop.
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 React from 'react'; | |
// Exercise 1: Passing props | |
// TODO: Make all the buttons pink | |
const Ex1 = () => { | |
// Pass the background color through to the components | |
const backgroundColor = 'black'; | |
return ( | |
<div> | |
<Toolbar /> | |
<ShoppingCart /> | |
</div> | |
) | |
}; | |
const Toolbar = () => { | |
return ( | |
<div> | |
<MyButton /> | |
</div> | |
) | |
}; | |
const ShoppingCart = () => { | |
return ( | |
<div> | |
<MyButton /> | |
</div> | |
) | |
}; | |
const MyButton = ({ backgroundColor = 'blue' }) => { | |
return <button style={{backgroundColor: backgroundColor}}>Click</button> | |
}; | |
// Exercise 2: context | |
export { Ex1 }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment