mikechau / react-primer-draft

A primer for building web applications with React.
Other
3.65k stars 104 forks source link

Clarify anti-pattern in getDefaultProps #3

Closed prakhar1989 closed 9 years ago

prakhar1989 commented 9 years ago

Don't use props to set your initial state. It's a anti-pattern and it is only acceptable, when you do something like call the prop something like: initialCount.

This is a bit unclear (since initailCount is not mentioned anywhere). I think you can update that section with the below snippet

getInitialState: function() {
   return {
     count: this.props.initialCount // this is fine
   }
}
mikechau commented 9 years ago

Updated!