代码之家  ›  专栏  ›  技术社区  ›  Mayank Jain Pushpendra Rathor

react native中出现意外错误

  •  0
  • Mayank Jain Pushpendra Rathor  · 技术社区  · 7 年前

    我是React Native的新成员,创建了一个用于学习的演示。我的数据细节文件第11行出错 datadetail.js意外令牌(11:2) . 下面是我的数据详细信息文件的代码。

    1. //DataDetail.js
    2. 
    3. import React from 'react';
    4. import {Text,View} from 'react-native';
    5. 
    6. const DataDetail = (props) => {
    7.  return (
    8.    <View>
    9.      <Text>{props.objData.title}</Text>
    10.    </View>>
    11.  );
    12. };
    13. 
    14. export default DataDetail;
    

    我从我的组件调用此组件:

    import DataDetail from './DataDetail';
    import React, {Component} from 'react';
    import {Text,View} from 'react-native';
    import axios from 'axios';
    
    export default class Home extends Component<Props> {
    
    state = {arrData:[]};
    
    componentWillMount(){
      axios.get('https://reduxblog.herokuapp.com/api/posts')
      .then(response => this.setState({arrData:response.data}));
    }
    
    renderList(){
      return this.state.arrData.map(data => <DataDetail key={data.id} objData={data} />);
    }
    
    render() {
      return (
        <View>
          {this.renderList()}
        </View>
      );
    }
    }
    

    有人能帮我理解一下,我在这里做错了什么吗?

    谢谢

    1 回复  |  直到 7 年前
        1
  •  1
  •   Dez    7 年前

    你有2个 > 当关闭 View 标签。

    6. const DataDetail = (props) => {
    7.  return (
    8.    <View>
    9.      <Text>{props.objData.title}</Text>
    10.    </View>
    11.  );
    12. };
    
    推荐文章