【问题标题】:React-Apollo : Passing components state to query variablesReact-Apollo:将组件状态传递给查询变量
【发布时间】:2018-06-27 23:57:03
【问题描述】:

是否有可能以某种方式将组件状态注入到查询选项中? 道具之类的?

options: (ownProps : any, ownState???) =>{
        console.log(a)
        return {
            variables: {
                name : ownProps.name
                id:  ownState.id <-------------------------

            }

【问题讨论】:

    标签: reactjs apollo react-apollo


    【解决方案1】:

    为了回答我自己的问题,我发现 Apollo 的 re-fetch 方法根据文档

    The variables argument will replace variables used with either the query option or the query from your graphql()

    这解决了问题。

    【讨论】:

      猜你喜欢
      • 2019-03-21
      • 2017-04-22
      • 2018-01-27
      • 2019-01-26
      • 2019-01-20
      • 2022-01-18
      • 1970-01-01
      • 2020-09-05
      • 2023-03-15
      相关资源
      最近更新 更多