Skip to content

Instantly share code, notes, and snippets.

@zHaytam
Created December 20, 2020 18:35
Show Gist options
  • Save zHaytam/a966a5034cf62cce09f39b522eff299b to your computer and use it in GitHub Desktop.
Save zHaytam/a966a5034cf62cce09f39b522eff299b to your computer and use it in GitHub Desktop.
import React, { useContext } from 'react';
import ThemeContext from './ThemeContext';
const styles = {
light: {
border: '1px solid black',
background: 'white',
color: 'black',
},
dark: {
background: 'black',
color: 'white',
},
};
function MyButton(props) {
const { theme } = useContext(ThemeContext);
return (
<button type="button" style={styles[theme]}>
{props.text}
</button>
);
}
export default MyButton;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment