Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Adopt React Hooks and "render props" style for core components #6

Open
pete-otaqui opened this issue Mar 13, 2019 · 1 comment
Open

Comments

@pete-otaqui
Copy link

Hi,

I've been looking at the various components here: https://project.marklogic.com/repo/projects/NACW, especially the "redux" based ones.

I'm recommending that, in the era of react 16.8+, with "hooks", that there is a cleaner pure react approach that might be a better fit. It would mean no requirement for redux, or as much configuration and plumbing to get up and running.

I've written a very simple example, querying the Github API rather than MarkLogic admittedly, here:

https://github.com/pete-otaqui/grove-hooks

As you can see in this project, there's still the clear split between "api" and "ui" components, which is great. You can hopefully also see that there are no other dependencies and the containing <App /> doesn't need any special treatment to get the <GithubSearch /> component running. Drop it in with a "render props" style child, and away you go.

Hope this is of interest.

@patrickmcelwee
Copy link

Pete, I don't have the time I want to dig into this at the moment, but I just wanted to say thanks for this, and I look forward to taking a much closer look.

I totally agree that hooks like useState() provide a wonderful interface, and that it can be helpful with the kinds of things you might reach for Redux for. One reason for keeping Redux is that we may support Angular UIs in the future - having a Redux layer with a good amount of business logic in it could allow us to reuse that logic in an Angular app as well. (We've had success with Angular + Redux in the past.) Whereas migrating it all to hooks means we've put it all into React, and can't get the logic back out.

And maybe there's some advantage to using both. I haven't looked yet at whether useState() and Redux play well together.

Anyway, mostly just wanted to let you know that we saw this and it is great! Hopefully, I can engage more substantively very soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants