javascript - 反应原生的意外错误
问题描述
我是 react-native 的新手,正在创建一个学习演示。我在第 1 行遇到错误。我的 DataDetail 文件中的 11 DataDetail.js Unexpected token (11:2)。下面是我的 DataDetail 文件的代码。
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>
);
}
}
任何人都可以在这里帮助我理解,我在这里做错了什么。
谢谢
解决方案
>
关闭View
标签时您有 2 个。
6. const DataDetail = (props) => {
7. return (
8. <View>
9. <Text>{props.objData.title}</Text>
10. </View>
11. );
12. };
推荐阅读
- javascript - 嵌套在数组中的对象是类的属性
- javascript - 我可以使用 for 循环迭代器作为 javascript 中的数组索引吗?
- firebase - 无法使用 cli 更新 firebase 函数,因为默认服务帐户不存在
- sql - PostgreSQL 将列类型从 DATERANGE 更改为 TSTZRANGE 并迁移数据
- javascript - 按下按钮后,Vue.js 会动态呈现 bootstrap-vue 组件
- docker - 在 Docker 高山容器中没有运行 /usr/sbin/crond 的输出?
- c++ - 这里的代码解释,C++ 中 cout 语句中的输出顺序
- swift - Swift:在节点之间接触时执行命令
- c# - 为什么我无法获得统一触摸输入?
- python - 总和为一个数字但最小化标准偏差的固定长度列表