Skip to content

Instantly share code, notes, and snippets.

@mattjstar
Last active June 5, 2016 23:20
Show Gist options
  • Save mattjstar/9a12073e28090a173098e4ab1f4bc033 to your computer and use it in GitHub Desktop.
Save mattjstar/9a12073e28090a173098e4ab1f4bc033 to your computer and use it in GitHub Desktop.
Presentational Components
import React from 'react';
import style from '../typography/typography.scss';
class Paragraph extends React.Component {
render() {
return (
<p className={style.para}>{this.props.children}</p>
);
}
}
Paragraph.propTypes = {
children: React.PropTypes.string.isRequired,
};
export default Paragraph;
// CAN BE REWRITTEN AS A STATELESS FUNCTIONAL COMPONENT (no life cycles or local state):
import React from 'react';
import style from '../typography/typography.scss';
const Paragraph = ({children}) => {
return (
<p className={style.para}>{children}</p>
);
}
export default Paragraph;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment