【问题标题】:GitHunt-React: Declaring `loading` Property?GitHunt-React:声明`loading`属性?
【发布时间】:2017-02-12 21:03:55
【问题描述】:

我已将 GitHunt-React 中的以下代码(以及我能找到的所有其他相关代码)复制到我的应用程序中。此代码来自 CommentsPage.js:

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

由于某种原因,在我的应用程序中,加载有时设置为 true,有时未定义。当我在 GitHunt-React 中单步执行此代码时(不是我的应用程序,而是原始示例代码),调用堆栈显示所有 React 内部函数,所以我无法将其追溯到 GitHunt-React 中声明 loading 的代码。此外,在 GitHunt-React 中对源代码进行文本搜索,似乎没有发现任何设置 loading. 值的内容

在 GitHunt-React 中,哪部分代码负责声明loading 并设置其值?

【问题讨论】:

    标签: reactjs graphql apollo apollostack


    【解决方案1】:

    loading 的值直接来自 Apollo Client,并通过 react-apollo 传递给 UI(本例中为 GitHunt-React)。

    【讨论】:

      猜你喜欢
      • 2012-11-23
      • 2015-09-26
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 2019-06-06
      相关资源
      最近更新 更多