在忽略错误并按照React Native Navigation 安装中的其余步骤操作后,我能够解决上一个问题。那些警告消失了。
但是,当我运行时npm run android,它构建成功但不启动应用程序
Configure project :app
...
Configure project :react-native-navigation
...
Task :app:installDebug
...
BUILD SUCCESSFUL in 6s
Run Code Online (Sandbox Code Playgroud)
Android 模拟器会转到主屏幕,并且应用程序不会启动。
Could not connect to development server我从白色的空白屏幕刷新。我已按照此处的步骤创建资产文件夹并运行此代码
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
Run Code Online (Sandbox Code Playgroud)// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = …Run Code Online (Sandbox Code Playgroud) macos android android-studio react-native react-native-navigation
我刚开始反应原生。我试图在我的 App.js 中嵌套多个导航。我已经成功地在我的BottomTabNavigation 中嵌套了一个StackNavigator,有 0 个问题我通过将它们的初始路由组件设置为等于先前的导航器来链接这些导航器。我试图在那里添加一个DrawerNavigation但一直收到错误。我所有的代码都在 1 个文件中(App.js)。我将如何处理这个问题?
堆栈导航器
const navigator = createStackNavigator(
{
Home: {
screen: HomeScreen,
navigationOptions: {
headerShown: false,
},
},
Favs: {
screen: CrossingScreen,
navigationOptions: {
title: 'News',
headerTitleStyle: {
color: 'white',
},
headerStyle: {
backgroundColor: 'red',
},
headerBackTitle: null,
headerTintColor: 'white',
},
},
},
{
initialRouteName: 'Home',
headerMode: 'screen',
})
Run Code Online (Sandbox Code Playgroud)
底部标签导航器
const TabNavigator = createMaterialBottomTabNavigator(
{
Home: {
screen: navigator,
navigationOptions: {
tabBarLabel: 'Home',
tabBarIcon: ({ tintColor …Run Code Online (Sandbox Code Playgroud) 我正在开发导航抽屉:
<Drawer.Navigator
initialRouteName={InitialScreen}
drawerContent={props => <MyDrawer {...props} />}
screenOptions={{
headerShown: true,
}}>
<Drawer.Screen name="main" component={MainScreen} />
</Drawer.Navigator>
Run Code Online (Sandbox Code Playgroud)
正如您在上面看到的,我通过实现我自己的组件来自定义抽屉的内容MyDrawer。
在渲染部分MyDrawer,我有:
return (
<View style={styles.myContent}>
<DrawerContentScrollView
style={{flex: 1, top: 0, bottom: 0, backgroundColor: 'yellow'}}
{...props}>
<View
style={{
backgroundColor: 'green',
flex: 1,
width: '100%',
height: '100%',
}}>
<View>
<DrawerItem name="Purhcase" text="Purchase" />
<DrawerItem name="Sell" text="Sell" />
</View>
...
</View>
</DrawerContentScrollView>
</View>
);
const styles = StyleSheet.create({
myContent: {
flex: 1,
paddingLeft: 0,
paddingTop: 10,
}
});
Run Code Online (Sandbox Code Playgroud)
我想要通过填充整个高度View来直接包裹绿色组件。上面的代码显示了我尝试过的内容,但无论我做什么,绿色 …
我搜索了这个错误,但没有找到解决方案。
TypeError: (0, _reactNativeScreens.useScreens) is not a function. (In '(0, _reactNativeScreens.useScreens)()', '(0, _reactNativeScreens.useScreens)' is undefined)
Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
Run Code Online (Sandbox Code Playgroud)
首先,我收到此错误```错误:错误:无法解析模块:react-native-screens在node_modules\react-native-stack\src\NavigatorIos\index.js项目中找不到react-native-screens。
After this error I installed
```npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view```
I am trying to run in android.
Run Code Online (Sandbox Code Playgroud) 我孜孜不倦地寻找这个问题的答案。
我有一个选项卡导航器:
const AppNavigator = () => {
return (
<Tab.Navigator initialRouteName="Search">
<Tab.Screen
name="Home"
children={() => <HomeScreen />}
options={{
tabBarIcon: ({ color, size }) => (
<MaterialCommunityIcons name="home" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="Search"
children={() => <SearchContainerNavigator />}
options={{
tabBarIcon: ({ color, size }) => (
<FontAwesome5 name="search" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="Feedback"
children={() => <FeedbackScreen />}
options={{
tabBarIcon: ({ color, size }) => (
<MaterialCommunityIcons name="email" color={color} size={size} />
),
}}
/>
</Tab.Navigator>
); …Run Code Online (Sandbox Code Playgroud) 在RNNavigation的第1版中,我通过这种方式将我的商店发送到每个屏幕.
Navigation.registerComponent(RouterConstants.SplashScreen, () => SplashScreen, store, Provider)
Run Code Online (Sandbox Code Playgroud)
编辑:
index.js:
import configureNavigation from './routers/app_navigation'
import createStore from './reducers'
const store = createStore()
configureNavigation(store, Provider)
class App extends React.Component {
constructor (props) {
super(props)
.
.
.
this.startApp()
}
startApp () {
Navigation.setRoot({
stack: {
children: [{
component: {
name: RouterConstants.SplashScreen
}
}]
}
})
}
}
const app = new App()
Run Code Online (Sandbox Code Playgroud)
app_navigation.js:
import SplashScreen from '../containers/splash_screen_container'
.....
...
const initializeRouter = (store, Provider) => {
Navigation.registerComponent(RouterConstants.SplashScreen, () => SplashScreen, store, …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试从V1升级到react-native-navigation V2,并试图找到一种方法来切换顶部栏按钮按下的侧面菜单.
我的应用程序开始
Navigation.setRoot({
root: {
sideMenu: {
left: {
component: {
name: 'testApp.SideDrawer',
passProps: {
text: 'This is a left side menu screen'
}
}
},
center: {
bottomTabs: {
...
}
},
},
},
});
Run Code Online (Sandbox Code Playgroud)
有没有办法在当前版本中执行此操作?
我有TabBar基础应用程序,在我的一个标签中我需要将其推送到另一个屏幕,但标签栏不应显示在推动的屏幕中.但是底部栏仍然存在于推动的屏幕中.我想要实现的并不是完全隐藏底部标签栏,而是将推动的屏幕放在标签栏的顶部.
这是我显示标签栏应用程序的代码:
bottomTabs: {
id: 'BottomTabsId',
children: [
{
stack: {
children: [
{
component: {
name: 'Home',
options: {
topBar: {
backButton: {
title: 'Back',
},
title: {
text: 'Home'
}
},
bottomTab: {
fontSize: 12,
text: 'Home',
icon: require('./src/assets/home.png'),
selectedIcon: require('./src/assets/home_active.png')
},
},
},
}
]
}
},
{
stack: {
children: [
{
component: {
name: 'Booking',
options: {
topBar: {
title: {
text: 'Booking'
}
},
bottomTab: {
text: 'Booking',
fontSize: 12,
icon: require('./src/assets/booking.png'), …
react-native react-native-navigation wix-react-native-navigation react-native-navigation-v2
我收到这个错误,它让我疯了,我甚至无法在React Native上启动一个简单的应用程序.我正在使用最基本的示例,一个新项目仍然会抛出此错误.我使用react-navigation v3xx 有人请帮助,因为我失去了理智,谢谢.这是我的代码:
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Button, TouchableHighlight} from 'react-native';
import { createAppContainer, createStackNavigator, StackActions, NavigationActions } from 'react-navigation'; // Version can be specified in package.json
class Home extends React.Component {
static navigationOptions = {
title: "Home",
}
render() {
return (
<View style={styles.container}>
<Text>Home Page</Text>
<Button onPress={() => this.props.navigation.navigate('About')} title="All about me" />
</View>
);
}
}
class AboutMeMe extends React.Component {
static navigationOptions = {
title: "All Me",
} …Run Code Online (Sandbox Code Playgroud) React Native和react-native-navigation的新手。该应用在iOS上可以正常运行,但是在启动时会很快抛出以下异常:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.engagereact, PID: 8105
java.lang.BootstrapMethodError: Exception from call site #3 bootstrap method
at com.reactnativenavigation.react.JsDevReloadHandler.<init>(JsDevReloadHandler.java:29)
at com.reactnativenavigation.react.ReactGateway.<init>(ReactGateway.java:29)
at com.engagereact.MainApplication.createReactGateway(MainApplication.java:29)
at com.reactnativenavigation.NavigationApplication.onCreate(NavigationApplication.java:28)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassCastException: Bootstrap method returned null
at com.reactnativenavigation.react.JsDevReloadHandler.<init>(JsDevReloadHandler.java:29)
at com.reactnativenavigation.react.ReactGateway.<init>(ReactGateway.java:29)
at com.engagereact.MainApplication.createReactGateway(MainApplication.java:29)
at com.reactnativenavigation.NavigationApplication.onCreate(NavigationApplication.java:28)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at …Run Code Online (Sandbox Code Playgroud)