我的App.js
import React from "react";
import { StyleSheet, Text, View, StatusBar, Button } from "react-native";
import { createStackNavigator, createAppContainer } from "react-navigation";
import NavigationService from "./NavigationService";
import Register from "./components/auth/Register";
import Login from "./components/auth/Login";
import SocketIOClient from "socket.io-client";
const AppNavigator = createStackNavigator({
Login: { screen: Login },
Register: { screen: Register }
});
const AppContainer = createAppContainer(AppNavigator);
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Register />
<StatusBar backgroundColor="#4d82cb" barStyle="light-content" />
<AppContainer
ref={navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef);
}}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#82b1ff",
alignItems: "center",
justifyContent: "center"
}
});
我从我的website中获取了我的NavigationService代码,并且
在Register.js中,我导入了NavigationService。
import NavigationService from "../../NavigationService";
<Button
style={styles.login}
onPress={() => {
NavigationService.navigate("Login");
}}
>
它引发不变违反:按钮的标题属性必须是字符串错误。它说未定义。
答案 0 :(得分:0)
按钮需要标题。 表格:
<Button title="Text you want" />
示例:
<Button title="Login" />