1. 程式人生 > >報錯 _react3.default.createClass is not a function

報錯 _react3.default.createClass is not a function

component point create sla contents 新版本 body values origin

這個是因為react最新版本拋棄使用了createClass這個函數,這個也是為了配合ES6 。這種情況下會報錯

var Popover = React.createClass({
propTypes: {
isVisible: PropTypes.bool,
onClose: PropTypes.func,
},

.........

........

........

應修改為下面的寫法:

export default class Popover extends React.Component{

getInitialState() {
return {
contentSize: {},
anchorPoint: {},
popoverOrigin: {},
placement: ‘auto‘,
isTransitioning: false,
defaultAnimatedValues: {
scale: new Animated.Value(0),
translate: new Animated.ValueXY(),
fade: new Animated.Value(0),
},
};
}

報錯 _react3.default.createClass is not a function