My App
component has a reload
button. Clicking reload
should essentially perform refetch by re-triggering the graphql query.
The way I am currently performing the reload is by using Apollos's refetch function when the user click reload
. However, the following error occurs when I click reload:
Here is my graphql HOC code:
const mapApiToProps = graphql(ASSETS_QUERY, {
props: ({ ownProps, data }) => {
return {
assets: data.assets,
isLoading: data.loading,
handleReload: data.refetch // Doesn't currently work
}
}
});
Here is my query:
export const ASSETS_QUERY = gql`
query getUserAssets {
assets {
body
id
}
}`
Here is my component code:
class App extends Component {
render() {
const {handleReload, isLoading, assets} = this.props;
return (
<div>
<ReloadBtn handleReload={handleReload} isLoading={isLoading} />
<AssetList assets={assets} />
</div>
)
}
}
And finally, my connect:
export default compose(
connect(mapStateToProps, mapDispatchToProps),
mapApiToProps
)(App);
Any insight into why the error occurs?