-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Container is not rerendered when calling refetch #2553
Comments
QueryRenderer should be used only for the first query (on root component, like the first react component in a route) Only your refetchContainer should rerender, check the docs https://facebook.github.io/relay/docs/en/refetch-container.html QueryRenderer won't rerender if you won't change variables |
@sibelius Issue persists even if the variables are different. The RefetchContainer does not rerender. |
create a small repro so we can test it |
@ntelkedzhiev I've made a comment here: ntelkedzhiev/relay-refetch@2b1084f#r31043442 |
@jgcmarins Thanks but this is unrelated (and false according to the docs). |
Any ideas? |
The most likely explanation for a RefetchContainer not updating is that the data being refetched doesn't overlap with the data that the fragment is selecting - usually because the variables don't line up. I would double check the query and variables. |
relay-dev-tools can help you with RelayNetworkLogger |
I did check the query and the variables. None of the usual solutions for this type of problems make sense here. As I said above, wrapping the relay refetch call in a simple |
The problem is here: relay/packages/react-relay/modern/ReactRelayRefetchContainer.js Lines 113 to 124 in d796497
For some reason the first refetch request passes the The relay code makes sense so I guess I'll have to wait until the first payload is rendered and only then refetch. What do you guys think? |
pass render-variables can resolve this issue in my project. const q = { effecting_true: 1 };
const vars = {
id: data?.id,
disablementQ: q,
};
refetchData(vars, {
q,
}); export default createRefetchContainer(
DriverDisablementCard,
{
data: graphql`
fragment DriverDisablementCard_data on Driver
@argumentDefinitions(q: { type: "JsonObject" }) {
id
disablements(before: null, first: 30, q: $q) {
nodes {
...DriverDisablementTable_data
}
}
}
`,
},
graphql`
query DriverDisablementCardQuery($id: ID!, $disablementQ: JsonObject) {
data: node(id: $id) {
...DriverDisablementCard_data @arguments(q: $disablementQ)
}
}
`
); |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@ntelkedzhiev did you ever work a way to do this other than waiting for the first payload to render? its still an issue in latest relay. |
Migrate to relay hooks, if the issue still valid, open another issue |
I'm using RelayCache to load the initial data and then calling
refetch
incomponentDidMount()
:However, the QueryRenderer does not render when the refetch is executed, nor the callback of the refetch function is called. What is more interesting is that if I wrap the refetch call into a setTimeout everything works fine:
Any suggestions why this is happening?
The text was updated successfully, but these errors were encountered: