import * as React from 'react';
import {Button, View, Text} from "react-native";
import Member from "./Signup"
import { withNavigation } from "react-navigation";
import { useNavigation } from '@react-navigation/native';
import {createAppContainer} from "react-navigation"
export default function App (){
return (
<View>
<Text>Hello App Sean</Text>
<Button
onPress = {()=>navigation.navigate("Member")}
title="Redirect"/>
</View>
);
}
import React from "react";
import {View, Text} from "react-native";
import { createStackNavigator } from '@react-navigation/stack';
export default class Member extends React.Component{
render(){
return (
<View>
<Text>Sign Up Sean!!!</Text>
</View>
)
}
}
以上是我的主文件。注册文件中的“我的会员”组件是第二个。我想单击我的按钮,然后重定向到“注册”屏幕。我该怎么办?我整天都在搜寻Google,但似乎还没有找到合适的解决方案。请帮帮我。
有点偏离主题,但我建议您使用React-router(对于RN),并与useHistory挂钩结合使用,您不会遇到这些问题。 replace() or push()
方法的基本用法将很容易操纵路线之间的导航。
首先,您必须创建一个堆栈导航器,将其称为navigator.js: