【问题标题】:Can I pass state at the time of navigator dispatch method calling in react-native?我可以在导航器调度方法调用 react-native 时传递状态吗?
【发布时间】:2018-11-01 10:29:59
【问题描述】:

我想在调用调度操作时在抽屉菜单/导航器上传递一个状态。

<Button
title='Filter'
onPress={() => navigation.dispatch(DrawerActions.openDrawer())}
/>

【问题讨论】:

    标签: react-native navigation-drawer


    【解决方案1】:

    您应该调用您的调度函数并使用 this.props.navigation.setParams 设置组件何时挂载

    在你的组件中设置调度函数

    this.props.navigation.setParams({
       dispatch: this.dispatch.bind(this)
    })
    
    dispatch(){
     //your code
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-02
      相关资源
      最近更新 更多