您忘记合上
Class支架了。
class AddAddressComponent extends React.Component { render() { let {provinceList,cityList} = this.props if(cityList === undefined || provinceList === undefined){ console.log('undefined props') } else { console.log('defined props') } return ( <div>rendered</div> ) }}AddAddressComponent.contextTypes = { router: React.PropTypes.object.isRequired};AddAddressComponent.defaultProps = { cityList: [], provinceList: [],};AddAddressComponent.propTypes = { userInfo: React.PropTypes.object, cityList: React.PropTypes.array.isRequired, provinceList: React.PropTypes.array.isRequired,}ReactDOM.render( <AddAddressComponent />, document.getElementById('app'))<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script><div id="app" />
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)