top | item 31965315

(no title)

blindmute | 3 years ago

It's a great benefit for a component to be able to specify what data it needs from remote without worrying about if an ancestor or sibling also needed it. React query will only fetch once the unique queries in the whole tree.

Without this feature, every component needing remote data D must share a parent ancestor fetching D for all of them, even when the children are not conceptually related. Adding another component higher in the tree means you have to hoist the fetcher up to that level, etc. React query is an incredible upgrade to anything else I've used over the years.

discuss

order

gofreddygo|3 years ago

> must share a parent ancestor fetching D for all of them

What happened to the whole "service" pattern? Isn't this the core problem it solved for Java in the 90's?

blindmute|3 years ago

An external service fetcher doesn't have integration with React because the entire tree potentially needs to know when the data changed. Once you write the code to subscribe to those changes where necessary, you've basically invented another state library.