React.createElement : 类型不应为空

React.createElement : type should not be null

我从 here 复制了代码。

这会引发此警告:

.

如何修复此警告?

代码:

'use strict';
var React = require('react-native');
 // I have import the ScrollView and RefreshControl
var{
    StyleSheet,
    Image,
    ScrollView,
    RefreshControl,
    View,
    } = React;
var Carousel = require('react-native-looped-carousel');
var Dimensions = require('Dimensions');
var {width, height} = Dimensions.get('window');
 
var NewsListView = React.createClass({
    getInitialState: function () {

        return {

            isRefreshing: false,
            loaded: 0,

        };
    },
 
    componentDidMount: function () {
    }, 
    render: function () {
        return (
      // if I remove  RefreshControl , the warming missing. how to fix this problem
            <ScrollView
                style={styles.scrollview}
                refreshControl={
          <RefreshControl
            refreshing={this.state.isRefreshing}
            onRefresh={this._onRefresh}
            tintColor="#ff0000"
            title="Loading..."
 
          />
        }>
 
                <View>
                    <Carousel delay={5000} style={{width: width, height: height/4 }}>

                        <Image
                            source={require('RT_XiaoYiSiGou/Image/img_banner.png')
                    }
                            style={{width: width, height: height/4}}
                        />
                        <Image
                            source={require('RT_XiaoYiSiGou/Image/img_banner2.png')}
                            style={{width: width, height: height/4}}

                        />
                        <Image
                            source={require('RT_XiaoYiSiGou/Image/img_banner3.png')}
                            style={{width: width, height: height/4}}

                        />
                    </Carousel>
                </View>
            </ScrollView>
        );
    },


    _onRefresh() {
        this.setState({isRefreshing: true});
        setTimeout(() => {
            this.setState({
                loaded: this.state.loaded + 10,
                isRefreshing: false,
            });
        }, 5000);
    },

});

var styles = StyleSheet.create({
    scrollview: {
        flex: 1,
    },
});

module.exports = NewsListView;

我 "suggest" 因为我不能从你的代码中做更多的事情是:

1) 你得到的错误是因为你没有正确调用React.createElement。您应该将代码编写成简单的片段,我建议将其分成三部分,定义、创建和渲染...

// define your element
var definitionObject = {

  // a property called render which is a function which returns your markup.
  render: function() {
    return (
      <h1 className="peterPan">
        Peter Pan.
      </h1>
    );
  }
}

// create the actual element
var PeterPanElement = React.createClass(definitionObject);


ReactDOM.render(
  <PeterPanElement />,
  document.getElementById('willBeReplacedByPeterPanElement')
);

我希望你同意我无法从你的问题中推断出更多,如果你清理问题,我们可能会帮助你更多...