jouerai
jouerai

Reputation: 135

Refetch method for createRefetchContainer doesn't execute callback

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?

Upvotes: 0

Views: 250

Answers (1)

celticpride
celticpride

Reputation: 516

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

Upvotes: 1

Related Questions