0
私は以下のapollo-graphqlクライアントサイドコードを持っています。ここで30秒ごとにgraphqlクエリをトリガしてデータを取得します。Apollo Graphql:再取得中にインジケータを読み込まないようにする
import React, { Component } from 'react';
import { gql, graphql } from 'react-apollo';
import _ from 'underscore';
class Test extends Component {
render() {
if (this.props.TestData.loading) {
return <div>Loading...</div>
}
if (this.props.TestData.error && this.props.TestData.error !== null) {
return <div>Error...</div>
}
// Iterate through the this.props.TestData.getTestData and build the Table of data here
return (
<table>
_.map(this.props.TestData.getTestData.testList, (test) => {
<tr>
<td>{test.testName}</td>
<td>{test.status}</td>
</tr>
})
</table>
);
}
}
const TestQuery = gql`
query TestQuery() {
getTestData() {
testList {
testName
status
}
}
}
`;
const options =() => ({
pollInterval: 30000,
});
const withTestData = graphql(TestQuery, {
name: 'TestData',
options,
});
export default withTestData(Test);
私が直面している問題は、クエリが再トリガされているので、すべてが30秒後に、私はLoading...
を参照してくださいということです。 Loading...
は、ページが起動されたときにのみ表示され、その後はスムーズな更新が必要で、ユーザーにLoading...
インジケーターを表示したくない場合があります。これを達成する方法がわかりません。
素晴らしいです。否定が見つからず、正しいフィールドを指すように変更されたため、コードを編集しました。 –