Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

[Feature idea] onLoaded event for Query component #1927

Closed
javorosas opened this issue Apr 15, 2018 · 2 comments
Closed

[Feature idea] onLoaded event for Query component #1927

javorosas opened this issue Apr 15, 2018 · 2 comments

Comments

@javorosas
Copy link

javorosas commented Apr 15, 2018

I have an use case that could justify the need for an onLoaded/onComplete event for the Query component. It goes like this:

I have a select input that loads its options asynchronously based on a query. When the query loads, I need to populate my select's options and select the first option by default.

For now I can achieve this using the HOF and the (soon-to-be-deprecated) componentWillReceiveProps:

...
componentWillReceiveProps (props) {
  if (!props.loading && !props.error && props.data.options.length > 0 && !this.state.selected) {
    this.setState({ selected: props.data.options[0].value });
  }
}
...

I can't see how this can be achieved using the Query component without having an event which fires up when the query has been fetched (similar to the one the Mutation component has). Any ideas?

@javorosas
Copy link
Author

Didn't notice this is duplicated from #1862 and being addressed in #1922. Closing.

@tab00
Copy link

tab00 commented May 16, 2018

We need onLoaded in Query. What's going on?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants