[英]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.