[英]Android Application Emulator keeps stopping on React Native
I was editing one of the '.js' files and after saving my work after some changes, when I typed 'rr' to refresh application on the emulator, I kept getting this message. 我正在编辑其中一个“ .js”文件,并在进行一些更改后保存了工作,当我键入“ rr”以刷新模拟器上的应用程序时,我一直收到此消息。
Android Application Emulator keeps stopping App info Close app Android应用程序模拟器不断停止应用程序信息关闭应用程序
enter image description here 在此处输入图片说明
After creating Form.js and under a components folder in my project in the visual studio code editor and importing it in my Login.js that's where the error started to occur. 在Visual Studio代码编辑器中的项目中,在我的项目中的Form.js文件夹中创建Form.js之后,将其导入到我的Login.js中 ,这是开始发生错误的地方。 IDK what I did wrong. IDK我做错了什么。 I'm new to React Native and am just learning. 我是React Native的新手,正在学习。
Form.js Form.js
import React, {Component} from 'react';
import {
StyleSheet,
Text,
View,
TextInput
} from 'react-native';
export default class Login extends Component<{}> {
render(){
return(
<View style={styles.container}>
<TextInput style={styles.inputBox}
underlineColorAndroid='rgba(0,0,0,0)'
placeholder="Email"
placeholderTextColor = "#ffffff"
/>
<TextInput style={styles.inputBox}
underlineColorAndroid='rgba(0,0,0,0)'
placeholder="Password"
placeholderTextColor = "#ffffff"
/>
</View>
)
}
}
const styles = StyleSheet.create({
container : {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
inputBox: {
width:300,
backgroundColor:'rgba(255,255,255,0.3)',
borderRadius: 25,
paddingHorizontal: 16,
fontSize: 16,
color:'#ffffff',
marginVertical: '10'
}
});
Login.js Login.js
import React, {Component} from 'react';
import {
StyleSheet,
Text,
View,
StatusBar
} from 'react-native';
import Logo from '../components/Logo';
import Form from '../components/Form';
export default class Login extends Component<{}> {
render () {
return(
<View style={styles.container}>
<Logo/>
<Form/>
</View>
)
}
}
const styles = StyleSheet.create({
container : {
backgroundColor: '#29b6f6',
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});
Here is your solution 这是您的解决方案
Your application is crashed because of this props underlineColorAndroid="rgba(0,0,0,0)" in your TextInput and also minor change in inputBox style remove string value marginVertical: "10" to marginVertical: 10 由于TextInput中的以下属性underlineColorAndroid =“ rgba(0,0,0,0)” ,您的应用程序崩溃,并且inputBox样式中的微小更改也将字符串值marginVertical:“ 10”更改为marginVertical:10
Form.js Form.js
import React, { Component } from "react";
import { StyleSheet, Text, View, TextInput } from "react-native";
export default class Login extends Component {
render() {
return (
<View style={styles.container}>
<TextInput
style={styles.inputBox}
// underlineColorAndroid="rgba(0,0,0,0)"<---Comment this code---
placeholder="Email"
placeholderTextColor="#ffffff"
/>
<TextInput
style={styles.inputBox}
// underlineColorAndroid="rgba(0,0,0,0)"<---Comment this code---
placeholder="Password"
placeholderTextColor="#ffffff"
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center"
},
inputBox: {
width: 300,
backgroundColor: "rgba(255,255,255,0.3)",
borderRadius: 25,
paddingHorizontal: 16,
fontSize: 16,
color: "#ffffff",
marginVertical: 10 <-----Remove string to number---
}
});
Output :-- 输出 :-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.