Live data from Hacker News

Redux-query – A React/Redux library for querying and managing network state

amplitude.engineering

41–50 of 63 posts

Re: Redux-query – A React/Redux library for querying and managing network state

#41

I'm very surprised that Relay is not getting more traction in this space. Given, it's a lot of work to get it set up and running but once it's in place it's great. I haven't found a library that manages network state and the associated difficulties that come with it better. No reason why you cannot combine both Redux + Relay, in fact once the app gets to a certain size and you want to rely less on passing around long…

We built a new GraphQL client that makes it especially easy to integrate with Redux, which also handles all of the related concerns about data caching and state management: http://dev.apollodata.com/

Re: Redux-query – A React/Redux library for querying and managing network state

#42
post #2

I love react, with the reusable components and the ergonomic of jsx but I really don't like what redux does to your code: it involves too much magic, you lose the concept of independent components and every change becomes a global one: everybody is notified of the inner state of each component … To me it just break all encapsulation and just lead to massive tangled code that is really hard to maintain … Edit: I want…

Redux Form really goes against the spirit of Redux in my opinion. It uses Redux internally, but you can't really directly access the reducer it uses, so from the user's perspective it is almost like it's not using Redux. The one serious library choice mistake I made in my first React/Redux app was using Redux Form. It was almost impossible to do things if the library hadn't anticipated my exact use case. I ended up having to rip out a bunch of code, and I switched to React Redux Form[1] even though it was a very immature library at the time.

[1]: https://github.com/davidkpiano/react-redux-form

Re: Redux-query – A React/Redux library for querying and managing network state

#43
post #2

I love react, with the reusable components and the ergonomic of jsx but I really don't like what redux does to your code: it involves too much magic, you lose the concept of independent components and every change becomes a global one: everybody is notified of the inner state of each component … To me it just break all encapsulation and just lead to massive tangled code that is really hard to maintain … Edit: I want…

Redux uses Event Sourcing. ES's trade-offs apply.

Its evented, not normally event-sourced. I don't know of many production uses of redux that also store the events for replay.

Re: Redux-query – A React/Redux library for querying and managing network state

#44

This looks like a really great library for simplifying API interactions. I'm curious though if there's any way to indicate that a component depends on more than one end point. Would you just wrap it in multiple `connectRequest` wrappers?

Author here. Thanks! That's what we do. It's an OK workaround but ideally `connectRequest` would support multiple queries. Another workaround is to manually dispatch `requestAsync` actions, which might be necessary if you need to chain the requests.

Does it de-dupe requests if multiple components need the same URL?

Re: Redux-query – A React/Redux library for querying and managing network state

#45
post #5
post #2

I love react, with the reusable components and the ergonomic of jsx but I really don't like what redux does to your code: it involves too much magic, you lose the concept of independent components and every change becomes a global one: everybody is notified of the inner state of each component … To me it just break all encapsulation and just lead to massive tangled code that is really hard to maintain … Edit: I want…

Depends on how you use it. I just keep my application state in redux. Redux itself has absolutely no magic. The only "magic" I see is when you add state diffing and memoization (reselect). And even in this case, it's not really hard to understand what's happening. React with redux is just a big pubsub system, how you set up your application state and how each component interacts with that state will decide how "tangl…

Reselect is super opaque. Very difficult to understand what is happening with reselect from my experience.

Agree with all your other points though.

Re: Redux-query – A React/Redux library for querying and managing network state

#46

Earlier quoted context omitted.

Author here. Thanks! That's what we do. It's an OK workaround but ideally `connectRequest` would support multiple queries. Another workaround is to manually dispatch `requestAsync` actions, which might be necessary if you need to chain the requests.

We were just about to start migrating to GraphQL and Apollo, so this definitely came out at the right time. Our issue is that our API is nested, and does require many nested requests. This would probably be the best solution for us though. Unfortunately, I don't see anything related to server-side rendering?

Yeah server-side rendering hasn't been a focus for us. Currently, I don't think it is a great solution for server-side-rendered apps. I'm not exactly sure how much it would take to improve things here.

If you have any thoughts around multiple requests or server-side rendering feel free to submit an issue on Github to discuss! https://github.com/amplitude/redux-query/issues

Re: Redux-query – A React/Redux library for querying and managing network state

#47
post #42
post #2

I love react, with the reusable components and the ergonomic of jsx but I really don't like what redux does to your code: it involves too much magic, you lose the concept of independent components and every change becomes a global one: everybody is notified of the inner state of each component … To me it just break all encapsulation and just lead to massive tangled code that is really hard to maintain … Edit: I want…

Redux Form really goes against the spirit of Redux in my opinion. It uses Redux internally, but you can't really directly access the reducer it uses, so from the user's perspective it is almost like it's not using Redux. The one serious library choice mistake I made in my first React/Redux app was using Redux Form. It was almost impossible to do things if the library hadn't anticipated my exact use case. I ended up h…

Honest question, what is the reason for using a global store for form validation? That seems like the ideal use-case for local component state.

Re: Redux-query – A React/Redux library for querying and managing network state

#48
post #47
post #42

Earlier quoted context omitted.

Redux Form really goes against the spirit of Redux in my opinion. It uses Redux internally, but you can't really directly access the reducer it uses, so from the user's perspective it is almost like it's not using Redux. The one serious library choice mistake I made in my first React/Redux app was using Redux Form. It was almost impossible to do things if the library hadn't anticipated my exact use case. I ended up h…

Honest question, what is the reason for using a global store for form validation? That seems like the ideal use-case for local component state.

In my case, I had an editor for a structured document where the user could modify some parts of the document using a form and others using other components, some of which used forms internally. I wanted to have the whole document represented as an object in my Redux store that was also synced to the server.

Re: Redux-query – A React/Redux library for querying and managing network state

#49
post #48
post #47

Earlier quoted context omitted.

Honest question, what is the reason for using a global store for form validation? That seems like the ideal use-case for local component state.

In my case, I had an editor for a structured document where the user could modify some parts of the document using a form and others using other components, some of which used forms internally. I wanted to have the whole document represented as an object in my Redux store that was also synced to the server.

Gotcha, thanks!

Seems a shame that Redux-Form (and similar) are presented for more trivial solutions than yours. I don't see many forms that also need modification via 'other components', in a way in which that state can't just be handled by a sensible parent component.

Re: Redux-query – A React/Redux library for querying and managing network state

#50
post #33

Earlier quoted context omitted.

Redux is difficult to reason about because side-effects can be triggered from anywhere in the application by middleware. If you're using something like redux-thunk, a single dispatch can cause both a store mutation AND trigger a side effect, which is confusing. I'd rather have those be 2 separate concerns. Those dispatches can be triggered from anywhere in the app, and multiple middlewares may trigger multiple side-e…

yup. Its like i said: redux is simple. Middlewares are what makes it complicated. Redux-loop had a nice model for side effects, but the syntax did not mesh well with javascript limitations. Redux-saga is nice for testing, but it adds new non-standard concepts on top of generators that make it complicated. I really like the Netflix solution (redux-observable). Since JS is not Haskell, side effects can be shoved to the…

+1 for redux-observables, I've found RxJS to be an excellent tool for managing async without going insane.

I'd also second the notion to be rigorously consistent in following the semantics. I always end up regretting shortcuts.

Post reply on HN