Skip to content

Instantly share code, notes, and snippets.

@thomasboyt
Created January 10, 2016 20:58
Show Gist options
  • Save thomasboyt/867b9af6b948d41bfb6a to your computer and use it in GitHub Desktop.
Save thomasboyt/867b9af6b948d41bfb6a to your computer and use it in GitHub Desktop.

Reasons I don't use React's ES6 class syntax:

  • I like mixins! They should be applied carefully, but I find them easier to use than HOCs in many cases
    • Some useful libraries also still ship mixins instead of HOCs, and it'd be annoying to convert a component to createClass definition because I decided to use a mixin
  • I prefer defining propTypes/defaultProps in the component's body instead of as properties added after definition
  • I like auto-bound event handlers
  • I don't see any advantage to using ES6 classes for components
@graue
Copy link

graue commented Jan 11, 2016

  1. What sort of mixins are actively easier to use? Which libraries only ship mixins? (Another approach is, instead of rewriting the component to createClass, find a way to accomplish the goal without a mixin ๐Ÿ˜ )
  2. Yeah, hopefully this ES proposal will address that, but it seems like it might get held up by people complaining it doesn't let them omit semicolons. ๐Ÿ˜’
  3. Same as #2
  4. It reduces API surface area and makes Flow typing easier, for starters

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