[英]REACT-NATIVE SyntaxError unterminated JSX contents (57:41)
Help, Im trying code an app an I can't seem to get past this error. 帮忙,我正在尝试编写应用程序代码,但似乎无法克服此错误。
var React = require('react-native');
var {
View,
Text,
StyleSheet
} = React;
var styles = StyleSheet.create({
mainContainer: {
flex: 1,
padding: 30,
marginTop: 65,
flexDirection: 'column',
justifyContent: 'center',
backgroundColor: '#48BBEC'
},
title: {
marginBottom: 20,
fontSize: 25,
textAlign: 'center',
color: '#fff'
},
searchInput: {
height: 50,
padding: 4,
marginRight: 5,
fontSize: 23,
borderWidth: 1,
borderColor: 'white',
borderRadius: 8,
color: 'white'
},
buttonText: {
fontSize: 18,
color: '#111',
alignSelf: 'center'
},
button: {
height: 45,
flexDirection: 'row',
backgroundColor: 'white',
borderColor: 'white',
borderWidth: 1,
borderRadius: 8,
marginBottom: 10,
marginTop: 10,
alignSelf: 'stretch',
justifyContent: 'center'
},
});
class Main extends React.Component{
render(){
return (
<View style={styles.mainContainer}>
<Text> Testing the Router </Text>
</View>
)
}
};
module.exports = Main;
I believe the problem lies in this block 我相信问题出在这块
class Main extends React.Component{
render(){
return (
<View style={styles.mainContainer}>
<Text> Testing the Router </Text>
</View>
)
}
};
There error message is: SyntaxError /Users/tevinrivera/Rondeh/App/Components/Main.js: Unterminated JSX contents(57:41) 错误消息是:SyntaxError /Users/tevinrivera/Rondeh/App/Components/Main.js:JSX内容未终止(57:41)
Everything looks fine. 一切看起来都很好。 Try changing this code
尝试更改此代码
var React = require('react-native');
var {
View,
Text,
StyleSheet
} = React;
to this 对此
const React = require('React');
const ReactNative = require('react-native');
const{
StyleSheet,
View,
Text
} = ReactNative;
Your imports are wrong. 您的进口是错误的。 You need to import React from 'react' and other things like View, Stylesheet etc from 'react-native'.
您需要从“ react”中导入React,并从“ react-native”中导入其他视图,样式表等。
Something like will work: 类似的东西会起作用:
import React from 'react';
import {
View,
Text,
StyleSheet
} from 'react-native';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.