To expand a little what it means
getDefaultProps and propTypes are really just constructor properties.
the "on the constructor" bit is a weird wording. In the usual OOP language, this means that they are "static class variables"
class MyClass extends React.Component { static defaultProps = { yada: "yada" } ... }
or
MyClass.defaultProps = { yada: "yada" }
you can also refer to them in the class, for example:
constructor(props) { this.state = MyClass.defaultProps; }
or with something declared as a static class variable. I don’t know why this is not mentioned anywhere on the Internet regarding ES6 classes :?
see documents .
CpILL Jun 08 '16 at 7:45 2016-06-08 07:45
source share