Closed n1ru4l closed 2 years ago
@n1ru4l I find this PR interesting 👍
In practice, a management of observable fragments in which the user manages how and when to render the data.
@n1ru4l I find this PR interesting 👍
In practice, a management of observable fragments in which the user manages how and when to render the data.
Yes, basically how subscriptions are treated!
Due to the way relay-hooks is structured, it should also be integrated into the other hooks
next week I'll look deeper ;)
In the meantime, it would be nice to have other opinions as well (@sibelius )
I think it is good, we just need a better name
I'd like to hear if such a PR would be interesting in react-relay as well @jstejada, @rbalicki2
I have the need for subscribing to a fragment in a performant way in order to sync it with some not directly react related store. Doing that with
useFragment
andReact.useEffect
is not performant enough as the value updates quite frequently. For this use-case it would be beneficial to bypass re-renders and directly invoke some callback with the latest fragment data.The naming is debatable. It seems that in the react-three-fiber community by-passing render state is usually described as transient updates. I am happy to choose any other naming though. E.g.
useFragmentSubscription
,useSubscriptionFragment
.I originally posted the idea in the GraphQL Slack: https://graphql.slack.com/archives/C0BEXJLKG/p1618139127305000
@morrys Please let me know how you think about this addition 😇