Skip to content

Instantly share code, notes, and snippets.

@brownsmith
Created June 28, 2017 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brownsmith/37861814a0b5c6506a9aa7031e3d9cd5 to your computer and use it in GitHub Desktop.
Save brownsmith/37861814a0b5c6506a9aa7031e3d9cd5 to your computer and use it in GitHub Desktop.
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