React-apollo: Refactor to calculate `this.data` at render time

Created on 12 Oct 2016  路  1Comment  路  Source: apollographql/react-apollo

It seems like we are going through some contortions to keep this.data up to date, which seems unnecessary given we can now call this.queryObservable.currentResult() in the render function to get the current data.

So I would suggest something like:

render() {
  let data;
  if (/*skipping*/) {
    data = { loading: false, errors: null };
  } else {
    data = assign({}, this.queryObservable.currentResult());
    // copy fields over from queryObservable
  }

  // now render wrappedComponent with data
}

Most helpful comment

@tmeasday YES!! I love this idea!

>All comments

@tmeasday YES!! I love this idea!

Was this page helpful?
0 / 5 - 0 ratings