What is the equivalent of getDefaultProps function using ES6 in React Native? -
i looking @ documentation datepickerios component , use getdefaultprops() initialize props in component.
getdefaultprops: function () { return { date: new date(), timezoneoffsetinhours: (-1) * (new date()).gettimezoneoffset() / 60, }; }, getinitialstate: function() { return { date: this.props.date, timezoneoffsetinhours: this.props.timezoneoffsetinhours, }; },
what equivalent of using es6 syntax? because have been using:
constructor(props) { super(props); this.state = { //equivalent getinitialstate here }; }
should this.props = { } set default props?
see this:
https://github.com/facebook/react/issues/3725
class x extends react.component { } x.defaultprops = {...}
if using babel-plugin-transform-class-properties package, can this:
class x extends react.component { static defaultprops = {...} }
Comments
Post a Comment