Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 反应本机元素类型无效-导出_Reactjs_React Native - Fatal编程技术网

Reactjs 反应本机元素类型无效-导出

Reactjs 反应本机元素类型无效-导出,reactjs,react-native,Reactjs,React Native,非常新的react native,出现“元素类型无效错误” import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, ActivityIndicatorIOS, View } from 'react-native'; export default class SplashWalls extends Component { constructor(props)

非常新的
react native
,出现“元素类型无效错误”

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  ActivityIndicatorIOS,
  View
} from 'react-native';

export default class SplashWalls extends Component {

    constructor(props) {
    super(props);

    this.state = {
      wallsJSON: [],
      isLoading: true
    };
  }

  fetchWallsJSON() {
    var url = 'https://unsplash.it/list';
    fetch(url)
      .then( response => response.json() )
      .then( jsonData => {
        console.log(jsonData);

        this.setState({isLoading: false}); //update isLoading
      })
    .catch( error => console.log('Fetch error ' + error) );
  }

  componentDidMount() {
      this.fetchWallsJSON();
  }

  render() {
    var {isLoading} = this.state;
    if(isLoading)
      return this.renderLoadingMessage();
    else
      return this.renderResults();
  }

  renderLoadingMessage() {
    return (

   <View style={styles.loadingContainer}>
        <ActivityIndicatorIOS
          animating={true}
          color={'#fff'}
          size={'small'}
          style={{margin: 15}} />
          <Text style={{color: '#fff'}}>Contacting Unsplash</Text>

   </View>
    );
  }

  renderResults() {
    return (

   <View>
        <Text>
          Data loaded
        </Text>

   </View>
    );
  }

}

const styles = StyleSheet.create({
  loadingContainer: {
      flex: 1,
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#000'
  }
});

AppRegistry.registerComponent('SplashWalls', () => SplashWalls);
import React,{Component}来自'React';
进口{
评估学,
样式表,
文本,
活动指标,
看法
}从“反应本机”;
导出默认类扩展组件{
建造师(道具){
超级(道具);
此.state={
wallsJSON:[],
孤岛加载:正确
};
}
fetchWallsJSON(){
var url='1〕https://unsplash.it/list';
获取(url)
.then(response=>response.json())
.然后(jsonData=>{
console.log(jsonData);
this.setState({isLoading:false});//更新isLoading
})
.catch(错误=>console.log('Fetch error'+error));
}
componentDidMount(){
this.fetchWallsJSON();
}
render(){
var{isLoading}=this.state;
如果(孤岛加载)
返回此.renderLoadingMessage();
其他的
返回此.renderResults();
}
renderLoadingMessage(){
返回(
接触非闪光
);
}
renderResults(){
返回(
数据加载
);
}
}
const styles=StyleSheet.create({
装货集装箱:{
弹性:1,
flexDirection:'行',
为内容辩护:“中心”,
对齐项目:“居中”,
背景颜色:“#000”
}
});
AppRegistry.registerComponent('SplashWalls',()=>SplashWalls);
错误状态:

元素类型无效:应为字符串(对于内置组件) 或类/函数(用于复合组件),但得到:未定义。你 可能忘记了从中定义的文件导出组件

检查“飞溅墙”的渲染方法


有什么想法吗?

这里的问题是你的问题

<ActivityIndicatorIOS />

renderLoadingMessage(){
返回(
接触非闪光
)
}

尝试在构造函数中绑定渲染方法:
this。renderLoadingMessage=此。renderLoadingMessage.bind(this)
,与第二种方法相同。项目文件夹的名称是什么?只有墙吗?
<ActivityIndicator>
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  ActivityIndicator,
} from 'react-native';
renderLoadingMessage () {
    return (
      <View style={styles.loadingContainer}>
        <ActivityIndicator
          animating={true}
          color={'#fff'}
          size={'small'} 
          style={{margin: 15}} />
        <Text style={{color: '#fff'}}>Contacting Unsplash</Text>
      </View>
   )
 }