Refetch method for createRefetchContainer doesn't execute callback

六眼飞鱼酱① 提交于 2019-12-24 18:51:29

问题


My QueryRenderer uses the following Query: ```

graphql`
    query page_Query {
      viewer {
        id
        ...MountedRenderer_viewer
      }
    }
  `

and this is what my createRefetchContainer looks like: ```

createRefetchContainer(
  MountComponent,
  graphql`
    fragment MountedRenderer_viewer on User @argumentDefinitions(show: { type: "Boolean", defaultValue: false }) {
      id
      name @include(if: $show)

    }
  `,
  graphql`
    query OwnershipsRenderer_Query($show: Boolean!) {
      viewer {
        ...MountedRenderer_viewer @arguments(show: $show)
      }
    }
  `,
);

inside my MountComponent component I do this in componentDidMount: ```

this.props.relay.refetch(
        { show: true },
        err => {
            console.log('done!');
        },
        { force: true },
      );

I look into my store and I see that the data for "name" is fetched and merged with the store. However, the MountComponent does not get rerendered with the new data nor does it log "done". Shouldn't the MountComponent be subscribed to the viewer?


回答1:


I believe the signature of refetch is refetch(refetchVariables, renderVariable, observerOrCallback, options) so your callback should be the third argument.



来源:https://stackoverflow.com/questions/49647295/refetch-method-for-createrefetchcontainer-doesnt-execute-callback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!