jaydenseric / graphql-react

A GraphQL client for React using modern context and hooks APIs that is lightweight (< 4 kB) but powerful; the first Relay and Apollo alternative with server side rendering.
https://npm.im/graphql-react
MIT License
718 stars 22 forks source link

Consider adding HOCs #34

Closed vladshcherbin closed 5 years ago

vladshcherbin commented 5 years ago

Hey,

I've been looking at this project for a long time with a great desire to try it. I used render props in apollo and it was a horrible experience which I'd never want to have again. Luckily, apollo still has HOCs which are working fine and I'm one of a few happy devs who know they exist.

As I can see, in latest major version (8) hooks is the way to do things. However, I'm a huge fan of HOCs and this is the thing I would love to have before transitioning from apollo.

So my question is - maybe there is a chance to add HOCs support to this great package?

I know, they can be possibly created using current tools, but I'd prefer them built-in to be sure I didn't mess up with something, to know someone else might be using them (possibility to find bugs/ask features) and to have support from the author.

jaydenseric commented 5 years ago

Thanks for the kind words, and for the suggestion :)

I don't plan to add HoCs though, for 2 reasons:

  1. It would add surface area to the source, tests and docs.
  2. Hooks are the way to go, considering efficiency and ergonomics. We don't want there to be any ambiguity or confusion the best way to use this library.

You could probably make your own graphql-react HoCs without too much difficulty, but once you drop HoCs you won't want to go back!