简体   繁体   English

我尝试使用3反应导航版本运行我的drawerNavigation代码,但仍然说错误

[英]I have tried running my drawerNavigation code with 3 react navigation version but still says error

everyone, I have been trying to make my drawer navigation code work and it was saying that createAppContainer was undefined and that it wasn't a function. 大家好,我一直试图让我的抽屉导航代码工作,它说的是createAppContainer是未定义的,它不是一个函数。 So after some research, I tried to change react-navigation versions and another error persisted loading my bundler at only 19%. 因此,经过一些研究,我试图改变反应导航版本,另一个错误持续加载我的捆绑器只有19%。 Below I will post a screenshot of both errors from 3 react-navigation versions. 下面我将发布3个反应导航版本的两个错误的屏幕截图。

I have tried running the code with "react-navigation": "^2.18.3" the error was: 我试过用“react-navigation”运行代码:“^ 2.18.3”错误是:

(In '(0, _reactNavigation.createAppContainer)(navigator)', '(0, _reactNavigation.createAppContainer)' is undefined)

<unknown>
    App.js:46:34
loadModuleImplementation
    require.js:331:6
<unknown>
    index.js:7
loadModuleImplementation
    require.js:331:6
guardedLoadModule
    require.js:197:45
global code
    <unknown file>:0
"

As for "react-navigation": "^3.0.7" and "react-navigation": "^3.8.1" the errors were: 至于“react-navigation”:“^ 3.0.7”和“react-navigation”:“^ 3.8.1”错误是:

Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module `./createNavigationContainer` from `/Users/camillebasbous/Project/node_modules/react-navigation/src/react-navigation.js`: The module `./createNavigationContainer` could not be found from `/Users/camillebasbous/Project/node_modules/react-navigation/src/react-navigation.js`. Indeed, none of these files exist:
  * `/Users/camillebasbous/Project/node_modules/react-navigation/src/createNavigationContainer(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
  * `/Users/camillebasbous/Project/node_modules/react-navigation/src/createNavigationContainer/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)` (null))

__38-[RCTCxxBridge loadSource:onProgress:]_block_invoke.228
    RCTCxxBridge.mm:414
___ZL36attemptAsynchronousLoadOfBundleAtURLP5NSURLU13block_pointerFvP18RCTLoadingProgressEU13block_pointerFvP7NSErrorP9RCTSourceE_block_invoke.118
__80-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]_block_invoke
-[RCTMultipartStreamReader emitChunk:headers:callback:done:]
-[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:]
-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]
__88-[NSURLSession delegate_streamTask:didBecomeInputStream:outputStream:completionHandler:]_block_invoke
__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
-[NSBlockOperation main]
-[__NSOperationInternal _start:]
__NSOQSchedule_f
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_continuation_pop
_dispatch_async_redirect_invoke
_dispatch_root_queue_drain
_dispatch_worker_thread2
_pthread_wqthread
start_wqthread

Please, can anyone help? 拜托,有人可以帮忙吗?

import * as React from 'react';
import { Text, View, Image, ScrollView, StyleSheet } from 'react-native';
import {
  createDrawerNavigator,
  createAppContainer,
  DrawerItems,
  SafeAreaView,
} from 'react-navigation';



class Home extends React.Component {
  static navigationOptions = {
    title: 'Home',

  };

  render() {
    return (
      <View style={styles.container}>


      </View>
    );
  }
}





const navigator = createDrawerNavigator(
  {
    Home,

  },
  {
    // drawerType: 'back',
    // drawerPosition: 'right',
    // drawerWidth: 200,
    // drawerBackgroundColor: 'orange',
    // contentComponent: CustomDrawerContentComponent
  }
);

export default createAppContainer(navigator) ;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  }
});

You have to write this way to work this 你必须用这种方式来解决这个问题

const Navigation=createAppContainer(navigator)
export default Navigation;

I think this is a naming convention issue Please rename navigator to Navigator 我认为这是一个命名约定问题请将导航 器重命名为Navigator

const Navigator = createDrawerNavigator( { Home, }, 
{ // drawerType: 'back',
 // drawerPosition: 'right', 
// drawerWidth: 200, // drawerBackgroundColor: 'orange',
 // contentComponent: CustomDrawerContentComponent } );

 export default createAppContainer(Navigator) ; 

今天我尝试了Masuk Helal Anik和Vishal的方式,他们都工作,奇怪......

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有反应导航的 DrawerNavigation 标题 - Header for DrawerNavigation with react-navigation 我的 jsconfig.json 在反应 js 中出现错误,在 position 的 JSON 中说 throw err Unexpected token } - I have an error with my jsconfig.json in react js says throw err Unexpected token } in JSON at position 在 react js 中运行 npm-start 时出错。 尝试安装 sass 但仍然无法正常工作 - Error while running npm-start in react js. Tried installing sass but still not working onPress={() =&gt; this.props.navigation.openDrawer} 未在 react-native 中显示抽屉导航 - onPress={() => this.props.navigation.openDrawer} is not showing drawernavigation in react-native 我的代码中有错误反应 js 项目 - i have an error in my code react js project 我的 React 版本有问题 - I have a problem with my version of React 我已经在我的 React 网页中导入了 useState 但它仍然显示编译错误 - I have already imported useState in my React webpage but it is still showing compilation error 即使我在后台运行了模拟器,也无法运行我的React本机代码 - I can't run my react native code even though I have an emulator running in the back round 此javascript代码在没有for循环的情况下可以正常运行,但是没有循环。任何帮助,我都尝试了一切 - This javascript code is running properly without the for loop but not with it.Any help, I have tried everything 使用 react-bootstrap 时出现模块未找到错误。 已尝试所有步骤 - I have module not found error while working with react-bootstrap. Have tried all the steps
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM