Created
June 28, 2017 07:18
-
-
Save brownsmith/37861814a0b5c6506a9aa7031e3d9cd5 to your computer and use it in GitHub Desktop.
Stateless functional component in React
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 PropTypes from 'prop-types'; | |
import React from 'react'; | |
import styles from './Component.scss'; | |
const ComponentName = ({ prop, anotherProp, functionFromContainer, propsAreFromContainer, prop2 }) => { | |
const someConstant = constantVal; | |
const componentClickEvent = () => { | |
// do whatever, perhaps with someConstant; | |
}; | |
const overlayClicked = () => { | |
closeCalendar(); | |
}; | |
return ( | |
<div className={styles.cssClass}> | |
<div onClick={_componentClickEvent}>Component details</div> | |
</div> | |
); | |
}; | |
ComponentName.propTypes = { | |
prop: PropTypes.object, | |
anotherProp: PropTypes.object, | |
functionFromContainer: PropTypes.func, | |
propsAreFromContainer: PropTypes.string, | |
prop2: PropTypes.func | |
}; | |
export default ComponentName; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment