Ben
05/01/2020, 3:20 AM<Query query={ALL_SEARCHES_QUERY}>
{({ error, loading, data }) => {
if (error) return <p>Error!</p>;
if (loading) return <p>Loading...</p>;
this.handleData(data);
return <div>query stuff</div>;
}}
</Query>
this.handleData():
handleData = (data) => {
data.allSearches.map((datum) => {
console.log(
`This is the title: ${datum.title} - and this is the URL: ${datum.url}`
);
});
};
Expected console output:
This is the title: titleone - and this is the URL: urlone
This is the title: titletwo - and this is the URL: urltwo
Console output when page loads:
This is the title: titleone - and this is the URL: urlone
This is the title: titletwo - and this is the URL: urltwo
This is the title: titleone - and this is the URL: urlone
This is the title: titletwo - and this is the URL: urltwo
I used "titleone", "titletwo", etc to save space. I am getting the correct variables there, but as you can see it is happening twice. Does anyone have any idea why??? Any help is much appreciated!