Why am I unable to link the settings screen to the login/registration screen after clicking on the name and I keep getting the error "undefined is not a function"?
P粉399090746
P粉399090746 2023-09-16 10:45:09
0
1
614

I'm trying to do a simple task of jumping from one screen to another, but no matter what I do it doesn't work. I have installed react-navigation/stack and react-navigation/native-stack but neither of them work with my existing code, is it because of the tabs?

import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import Tabs from './navigation/tabs';
import "react-native-url-polyfill/auto"
import LogInSignUp from './SettingsScreen/LogInSignUp';


const Stack = createStackNavigator();

const App = () => {
    return (
        <NavigationContainer>
          <Stack.Navigator screenOptions={{ headerShown: false }}>
            <Stack.Screen name="Home" options={{title: "Welcome"}} component={Tabs} />
            <Stack.Screen name="Settings" component={Tabs} />
            <Stack.Screen name = "LogInSignUp" component={LogInSignUp}/>
          </Stack.Navigator>
    </NavigationContainer>
  );
};

export default App;

import { Text, StyleSheet, View, Button, } from "react-native";
import { StatusBar } from "expo-status-bar";


const Settings = (navigation) => {
    return (
      <View style = {styles.container}>
        <Button title = "LogIn/SignUp" onPress={() => navigation.navigate("LogInSignUp")}></Button>
      </View>
      
    );
  }

  const styles = StyleSheet.create({
    container: {
      flex: 1,
      alignItems: 'center',
      justifyContent: 'center',
    },
    
  })

export default Settings

import React from 'react'
import { StackActions } from '@react-navigation/native';

const LogInSignUp = (navigation) => {
  return (
    <div>LogInSignUp</div>
  )
}

export default LogInSignUp

I tried looking up tutorials that explain this problem, all their code looks like my code, just changing the name to my .js file, but nothing works.

P粉399090746
P粉399090746

reply all(1)
P粉342101652

Have you tried this hook

const navigation = useNavigation();

import {useNavigation} from '@react-navigation/native';

const Settings = () => {
const navigation = useNavigation();
    return (
      <View style = {styles.container}>
        <Button title = "登录/注册" onPress={() => navigation.navigate("LogInSignUp")}></Button>
      </View>
    );
  }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!