Last active
August 17, 2019 22:24
-
-
Save esr360/12e8005ab8e44ee2a28e9b6853d1f81d 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, { useState, useContext } from 'react'; | |
import someContextObject from '../someContext'; | |
const useStyles = ({ props, state, context }) => ({ | |
... | |
}); | |
const MyComponent = (props) => { | |
const [isActive, setActive] = useState(false); | |
const context = useContext(someContextObject); | |
const styles = useStyles({ props, context, state: { isActive } }); | |
return ( | |
<div style={styles} onClick={() => setActive(!isActive)}> | |
<div style={styles.heading}>{props.heading}</div> | |
<div style={styles.content}>{props.children}</div> | |
</div> | |
) | |
} | |
export default MyComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment