如何在点击router-flux的后退按钮后立即调用一个函数?

时间:2017-09-01 00:44:24

标签: react-native react-native-router-flux

我正在使用react-native-router-flux版本3.38.0。当我点击router-header上的后退按钮时,我需要调用一个动作创建者或一个函数。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

您可以在路由器通道renderBackButton组件上轻松使用Scene道具。使用此道具,您必须调用闭包/函数来实现自定义后退按钮。

import LeftButton from '...';

...

<Scene
  key="yourSceneKey"
  component={YourSceneComponent}
  title="Your Scene Title"
  renderBackButton={() => 
    <LeftButton 
      leftButtonIcon={"arrow-back"} 
      onLeft={() => Actions.pop()} 
      leftButtonColor={"white"} 
      leftButtonIconSize={30} 
    />
  }
/>

参考:https://github.com/aksonov/react-native-router-flux/blob/v3/docs/API_CONFIGURATION.md