Skip to content

Instantly share code, notes, and snippets.

@krfong916
Created May 31, 2019 21:08
Show Gist options
  • Save krfong916/ffad566aaf372a702cd340628e87607b to your computer and use it in GitHub Desktop.
Save krfong916/ffad566aaf372a702cd340628e87607b to your computer and use it in GitHub Desktop.
A document detailing the tradeoffs we make in each of the ways that we can create components in React
// Component class
class Car extends Component {
constructor ( props ) {
super();
this.propertyA = this.propertyA.bind( this );
this.propertyB = this.propertyB.bind( this );
}
}
class ShoppingItem extends Component {
state = {}
render () {
return (
);
}
}
//
const Car = () => {
}
// Functional component
function Car = () => {
}
const Car = function () {
}
@krfong916
Copy link
Author

Component class

Explain

  • reason for super() keyword + constructor()
  • ES6 method shorthand
  • why we must term the properties defined in a class as 'properties' instead of 'methods'
  • classes are not statically declared, any modification to a parent changes children, breaking changes

Functional Component

  • factory pattern
  • es6 spreading

Hard-core Component creation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment