I have a display component wrapped in a Query
component to recieve data from a GraphQL query. After I perform a mutation, I have to refetch the data to update the store. The problem is that calling refetch()
results in the child component being unmounted, thus disrupting the interaction and scrolling that the user has been doing to cause the mutation.
Is there a way to call refetch()
without it causing the childen to unmount? If not, is there better way to the update the store that won't cause an unmount? Below is the code with the Query
component and its child.
<Query
query={query}
variables={{videoId}}
>
{
({loading, error, data, refetch }) => {
if (loading)
return <p>Loading...</p>;
if (error) {
console.log(error);
return <p>Error :(</p>;
}
const onChange = () => {
console.log("refetching");
return refetch();
}
const {timestampCollection} = data;
return(
<TimestampCollection onChange={onChange} player={this.state.player} timestampCollection={timestampCollection[0]} />
)
}
}
</Query>
Thank you all for the help!