3 ms·
So I spent some more time reading through using HOCs in React and I think I'll have to give functional components more of a try. The specific example I was thin
by dylanowen 4y ago
So I spent some more time reading through using HOCs in React and I think I'll have to give functional components more of a try. The specific example I was thinking of is https://github.com/graphql/graphiql/blob/50674292c55eadf0e61993ffbbc7a6983c608bf4/packages/graphiql-react/src/editor/response-editor.tsx#L37 https://github.com/graphql/graphiql/blob/50674292c55eadf0e61... but this component will probably always be complex because of the Codemirror interaction.
- codeptualize 4y agoNice! I think you might like it. Ah yeah, that does take a while to unpack. I think a lot of the complexity there is dealing with a non-react library and the dynamic import(s). Binding non-react libraries can be a bit rough. I do think it's a good example to show the big advantage of hooks, if you look at the use of the hook, super clean: https://github.com/graphql/graphiql/blob/50674292c55eadf0e61993ffbbc7a6983c608bf4/packages/graphiql-react/src/editor/components/response-editor.tsx#L9 https://github.com/graphql/graphiql/blob/50674292c55eadf0e61... Great way to contain complexity and make usage really clean and simple!