unused default export每当我将鼠标悬停export default emailChanged;在我的index.js文件中时,我都不明白我是如何出错的。我假设这就是我的代码无法在模拟器中运行的原因。
这是LoginForm.js:
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {emailChanged} from 'TorusTeensApp/src/actions';
import {Text, StyleSheet, KeyboardAvoidingView, TextInput, TouchableOpacity} from 'react-native';
class LoginForm extends Component {
onEmailChange(text) {
this.props.emailChanged(text);
}
render() {
return(
<KeyboardAvoidingView style={styles.container}>
<TextInput
style={styles.userInput}
onsubmitediting={() => this.passwordInput.focus()}
returnKeyType={"next"}
placeholder={"Email"}
label={"Email"}
keyboardType={"email-address"}
autoCorrect={false}
onChangeText={this.onEmailChange.bind(this)}
value={this.props.email}
/>
<TextInput
style={styles.userInput}
ref={(userInput) => this.passwordInput = userInput}
returnKeyType={"go"}
placeholder={"Password"}
label={"Password"}
secureTextEntry
/>
<TouchableOpacity style={styles.buttonContainer}>
<Text style={styles.buttonText}>Login</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.buttonContainer}> …Run Code Online (Sandbox Code Playgroud) 我在自学时React-Native遇到了这个奇怪的障碍。在 my 内部,App.js我尝试导出一个类,然后使用 myApp.js函数内的另一个文件somePage()。我正在拨打电话<Header/>,试图在点击后该文本出现在我的物理设备上refresh。
它显示<Login/>完美,但不是函数内的内容somePage()。我的问题是,为什么?
Expo(顺便说一下,我使用的不是一个index.ios.js文件,而是一个App.js仍然支持跨平台开发的文件)。
这是我的App.js文件:
import React, { Component } from 'react';
import {AppRegistry} from 'react-native';
import Login from './components/Login';
import Header from './components/Header';
export default class Project extends Component {
render() {
return (
<Login/>
);
}
}
const somePage = () => (
<Header/>
);
AppRegistry.registerComponent('someProject', () => Project);
AppRegistry.registerComponent('someProject', () => somePage); …Run Code Online (Sandbox Code Playgroud)