功能组件中的调用函数-headerRight按钮导航

时间:2019-09-16 19:08:32

标签: reactjs react-navigation native

我对带有反应导航的功能组件有疑问。

当我按下标题中的按钮时,无法在另一个函数中调用内部函数。

我的代码:

export default Consulta = ({ navigation }) => {

    const print = () => {

        [...]

    }
 }

Consulta.navigationOptions = props => ({

    title: props.navigation.getParam('title'),

    headerStyle: {
        backgroundColor: '#4f5f98',
    },
    headerTintColor: '#fff',
    headerTitleStyle: {
        fontWeight: 'bold',
    },
    headerRight: (
        <Button
          onPress={ ()=> Consulta.print() }
          title="Info"
          color="#12h"
        />
      ),

})

如何从Button headerRight中的onPress事件在Consulta中调用'PRINT'函数?

很抱歉我的英语水平,我是RN的新手。

谢谢

0 个答案:

没有答案