从带有功能组件的navigationOpstions中访问导航道具

时间:2019-08-23 19:43:01

标签: react-native react-navigation stack-navigator

我想在嵌套的堆栈导航标题中添加一个openDrawer按钮,为此,我需要从带有功能组件的navigationOpstions访问导航道具

那是我的代码:

import React from 'react'
import { StatusBar, TouchableOpacity, Text } from "react-native"
import { Container } from "./styles"
import HomeHeader from "./Header"
import HomeBody from "./Body"
import HomeFooter from "./Footer"

import Icon from "react-native-vector-icons/AntDesign"

import CoBrandConfig from "../../../config/CoBrand/config"

export default function Perfil ({ navigation }, props) {

  return(
    <Container>
      <StatusBar barStyle={`${CoBrandConfig.Home.HOME_STATUSBAR_CONTENT}`}
        backgroundColor={CoBrandConfig.Home.HOME_STATUSBAR_COLOR} />
      <TouchableOpacity onPress={() => navigation.navigate("PerfilEditar")}>
        <Text>EDITAR</Text>
      </TouchableOpacity>
      <HomeHeader />
      <HomeBody />
      <HomeFooter />
    </ Container>
  )
}

Perfil.navigationOptions = {
  headerLeft: <Icon.Button name={"menuunfold"} size={24} color={"#f2f2f2"} backgroundColor={"#229182"}
  onPress={() => this.navigation.navigate(openDrawer)}/>,
}

1 个答案:

答案 0 :(得分:1)

您可以将Perfil.navigationOptions分配给一个函数,该函数接受包含导航的对象,并返回navigationOptions对象。

ffmpeg -i TRACK-026.wav -filter_complex "channelsplit=channel_layout=4.0[Perche][MixHF][hf1][hf2]" -map "[Perche]" perche.wav -map "[MixHF]" MixHF.wav -map "[hf1]" hf1.wav -map "[hf2]" hf2.wav