VikR VikR - 1 year ago 144
React JSX Question

GitHunt-React: Declaring `loading` Property?

I've duplicated the following code (and all the other relevant code I could find) from GitHunt-React to my app. This code is from CommentsPage.js:

const CommentsPageWithDataAndMutations = graphql(COMMENT_QUERY, {
options({ params }) {
return {
variables: { repoName: `${}/${params.repoName}` },
props({ data: { loading, currentUser, entry, updateQuery } }) {
return { loading, currentUser, entry, updateCommentsQuery: updateQuery };

For some reason in my app, loading is sometimes set to true, and sometimes is undefined.When I step through this code in GitHunt-React (not my app but the original sample code), the call stack shows all React internal functions, so I can't trace it back to the code in GitHunt-React that declares
. Also, doing a text search of the search code in GitHunt-React, doesn't seem to turn up anything setting the value of

In GitHunt-React, what part of the code is responsible for declaring
and setting its value?

Answer Source

The value of loading comes directly from Apollo Client, and is passed through react-apollo to the UI (GitHunt-React in this case).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download