使用反应导航构建应用程序。我有一个父组件,它从firebase中提取并在listview中呈现数据。列表视图渲染组件“ ListName”具有onRowPress函数,但是未定义this.props.navigation.navigate,因为导航不在该子组件的状态。
Ive尝试了多种方式将导航道具传递给孩子,也从孩子中的反应导航导入导航。没用。
谢谢!
这是我的rootStackNavigator:
const RootStackNavigator = StackNavigator(
{
Login: { screen: LoginScreen },
Main: { screen: MainTabNavigator },
Feedback: { screen: ProvideInstanceScreen }
},
{
navigationOptions: () => ({
//headerTitleStyle: {
//fontWeight: 'normal',
tabBarVisible: false,
header: null
//},
}),
}
);
Run Code Online (Sandbox Code Playgroud)
这是我的父组件(其状态为navigation.navigate)
import React from 'react';
import { ListView, StyleSheet, Text, Image } from 'react-native';
import { connect } from 'react-redux';
import _ from 'lodash';
import { MainButton, GenSection } from '../components/common';
import { namesFetch } from '../actions'; …Run Code Online (Sandbox Code Playgroud)