抽屉导航内的嵌套堆栈导航

时间:2020-05-19 17:58:33

标签: react-native navigation-drawer stack-navigator

我正在尝试将堆栈导航嵌套在小吃博览会的抽屉导航中。我之前问过这个问题,并被告知要再做一次。我做到了,但仍然遇到不同的错误。如果有人能解释我在做什么错,我将不胜感激。如果有帮助,https://snack.expo.io/@andreeam/it-in-the-valley

也可以将链接发布到我的项目

谢谢

以下错误:

Device: (3:9741) (0,l.useLinkBuilder) is not a function. (In '(0,l.useLinkBuilder)()', '(0,l.useLinkBuilder)' is undefined)

我也得到

Device: (104:51757) r.render is not a function. (In 'r.render()', 'r.render' is undefined)

Cannot assign to read only property 'exports' of object '#<Object>'
  Evaluating module://react-native-screens.js
  Evaluating module://@react-navigation/drawer.js
  Evaluating module://App.js.js
  Loading module://App.js

这是我的app.js

import * as React from 'react';
import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';

import SignIn from './components/SignIn';
import ForgotPassword from './components/ForgotPassword';
import Dashboard from './components/Dashboard';
import Advertisers from './components/Advertisers';
import Adverts from './components/Adverts';
import Stats from './components/Stats';
import Plans from './components/Plans';
import ManageAdverts from './components/manageadvert';


const Stack = createStackNavigator();

class MyStack extends React.Component {
  render() {
    return (
    <Stack.Navigator
      initialRouteName="SignIn"
      screenOptions={{
        headerTitleAlign: 'center',
        headerStyle: { backgroundColor: '#2d3436'},
        headerTintColor: '#fff',
        headerTitleStyle: { fontWeight: 'bold'}
      }}>

      <Stack.Screen 
        name="Reset your password" 
        component={ForgotPassword} 
        options={
          {title: 'Reset your password'},
          {headerLeft: null} 
        } 
        />

      <Stack.Screen 
        name="SignIn" 
        component={SignIn} 
        options = {
          {headerShown: false,
          title: 'SignOut'}
        }
      />
      <Stack.Screen 
       name="Dashboard" 
       component={Dashboard} 
      />

      <Stack.Screen 
        name="Advertisers" 
        component={Advertisers} 
        options={
          {title: 'Advertisers'}
        } 
      />

      <Stack.Screen 
        name="Adverts" 
        component={Adverts} 
        options={
          {title: 'Adverts'}
        } 
      />
      <Stack.Screen 
        name="Stats" 
        component={Stats} 
        options={
          {title: 'Stats'}
        } 
      />
      <Stack.Screen 
        name="Plans" 
        component={Plans} 
        options={
          {title: 'Plans'}
        } 
      />

      <Stack.Screen 
        name="Manage Adverts" 
        component={ManageAdverts} 
        options={
          {title: 'Manage Adverts'}
        } 
      />
    </Stack.Navigator>
  );
}}


export default class App extends React.Component {
  render() {
  return (
    <NavigationContainer>
      <MyStack /> 
    </NavigationContainer>
);
}
}

1 个答案:

答案 0 :(得分:0)

将expo升级到版本37时出现此错误。我可以通过将相关的reactmodules更新到最新版本来解决此问题。