Got a job doing C# (blah) so I've been out of the ...
# orm-help
b
Got a job doing C# (blah) so I've been out of the react game a while. Trying to brush up and now I'm running into an issue. My prisma query is running twice when my page loads and I can't figure out why. Query:
Copy code
<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():
Copy code
handleData = (data) => {
    data.allSearches.map((datum) => {
      console.log(
        `This is the title: ${datum.title} - and this is the URL: ${datum.url}`
      );
    });
  };
Expected console output:
Copy code
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:
Copy code
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!