问题
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