标签: react-native-navigation

npm run android 不会启动 Android 应用程序

问题

在忽略错误并按照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 模拟器会转到主屏幕,并且应用程序不会启动。

我尝试过的

  • 我尝试过从 android studio 运行/构建/清理和重建。这导致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)

构建.gradle

// 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

3
推荐指数
1
解决办法
2万
查看次数

如何在 React Native v.5(不是 v.4)中嵌套多个导航器

我刚开始反应原生。我试图在我的 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)

navigation-drawer react-native react-native-navigation

3
推荐指数
1
解决办法
4095
查看次数

无法填充 DrawerContentScrollView 的整个高度

我正在开发导航抽屉:

<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来直接包裹绿色组件。上面的代码显示了我尝试过的内容,但无论我做什么,绿色 …

react-native react-native-navigation react-native-drawer

3
推荐指数
1
解决办法
5414
查看次数

类型错误:(0,_reactNativeScreens.useScreens)不是一个函数

我搜索了这个错误,但没有找到解决方案。

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-screensnode_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)

react-native react-native-navigation

3
推荐指数
1
解决办法
1750
查看次数

React Native 如何以编程方式导航到选项卡导航器上的堆栈屏幕

我孜孜不倦地寻找这个问题的答案。

我有一个选项卡导航器:

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)

react-native react-native-navigation

3
推荐指数
1
解决办法
4049
查看次数

将react-native-navigation V2与redux集成

在RNNavigation的第1版中,我通过这种方式将我的商店发送到每个屏幕.

Navigation.registerComponent(RouterConstants.SplashScreen, () => SplashScreen, store, Provider)
Run Code Online (Sandbox Code Playgroud)

但在V2中似乎没有用. 在此输入图像描述

编辑:

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)

react-native react-native-navigation

2
推荐指数
1
解决办法
2511
查看次数

按下按钮打开SideMenu

我目前正在尝试从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)

有没有办法在当前版本中执行此操作?

react-native-navigation react-native-navigation-v2

2
推荐指数
1
解决办法
3671
查看次数

WIX Navigation V2 - 推送到新屏幕时隐藏底部标签栏

问题说明

我有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

2
推荐指数
1
解决办法
2877
查看次数

React Native - undefined不是对象(评估'RNGestureHandlerModule.state')

我收到这个错误,它让我疯了,我甚至无法在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-ios react-native-navigation

2
推荐指数
1
解决办法
2889
查看次数

Bootstrap方法返回null-启动时Android立即崩溃

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)

android react-native react-native-navigation

2
推荐指数
1
解决办法
1189
查看次数