Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stateless functional component in React
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