Skip to content

Instantly share code, notes, and snippets.

@Toinne
Created February 22, 2020 17:55
Show Gist options
  • Save Toinne/e5f22c0a7319bd63a3ad09aa23867932 to your computer and use it in GitHub Desktop.
Save Toinne/e5f22c0a7319bd63a3ad09aa23867932 to your computer and use it in GitHub Desktop.
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