我试图在用户进入主屏幕后调用身份验证操作 . 我正在使用react-native router-flux与onEnter回调 .

我不能在我的场景中做到这一点,所以我用Action.refresh和传递道具动态地做它 .

问题是onEnter被多次调用 .

有没有其他方法可以知道用户何时进入主组件,以便我可以进行身份验证?

这是场景:

<Scene
    key="Home"
    component={Home}
    onEnter={this.props.param1}
     />

Bellow是Home组件,我正在使用alert来进行调试:

class Home extends Component {
  constructor(props) {
    super(props);
  }

  componentWillReceiveProps(props) {
    Actions.refresh({param1: () => alert('testing testing testing')}) 

  }