You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a centralized component that services other components in my application besides rendering its own UI (e.g. UndoManager). The render method of my centralized component renders and <Mutation/> with it UI rendered by the render prop. However I would like to have the ability to add the mutate callback to the central components state, so that I can add it to the components state and have it available for external calls from other components in my application.
I need to call setState() outside of the render function, otherwise react complains. I could just do a workaround by updating a variable on this or create a wrapper component reverting to the HOC approach, but a cleaner solution would be for the <Mutate/> component to provide onMount() and onUnMount() callbacks which are invoked on the underlying lifecycle event, so that I could setState in the proper place.
Proposed Solution:
add onMount((mutate) => this.setState(..)) and onUnMount(() => this.setState(..)) to <Mutation/>
Does not change current behavior
In general I think that Apollo team should see which callbacks on <Query/> and <Subscription/> could additionally be made accessible through onMount() and onUnMount() props.
The text was updated successfully, but these errors were encountered:
I'm doing a sweep of issues in this repo and came across this request. We will be deprecating the query components (including <Mutation />) in future major versions of the library in favor of hooks. Feel free to open a new feature request if you have suggestions on how to improve the hook-based API. Thanks!
Description:
I have a centralized component that services other components in my application besides rendering its own UI (e.g. UndoManager). The render method of my centralized component renders and
<Mutation/>
with it UI rendered by the render prop. However I would like to have the ability to add the mutate callback to the central components state, so that I can add it to the components state and have it available for external calls from other components in my application.I need to call setState() outside of the render function, otherwise react complains. I could just do a workaround by updating a variable on
this
or create a wrapper component reverting to the HOC approach, but a cleaner solution would be for the<Mutate/>
component to provide onMount() and onUnMount() callbacks which are invoked on the underlying lifecycle event, so that I could setState in the proper place.Proposed Solution:
add
onMount((mutate) => this.setState(..))
andonUnMount(() => this.setState(..))
to<Mutation/>
Does not change current behavior
In general I think that Apollo team should see which callbacks on
<Query/>
and<Subscription/>
could additionally be made accessible through onMount() and onUnMount() props.The text was updated successfully, but these errors were encountered: