I am new in react-native, creating a demo for learning. I am getting error in line no. 11 of my DataDetail file DataDetail.js Unexpected token (11:2) . Below is the code for my DataDetail file.
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;
I am calling this from my Component:
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>
);
}
}
Can anyone help me here to understand, what I am doing wrong here.
Thanks
You had 2 >
when closing the View
tag.
6. const DataDetail = (props) => {
7. return (
8. <View>
9. <Text>{props.objData.title}</Text>
10. </View>
11. );
12. };
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.