Hacker News new | ask | show | jobs
by softfalcon 1551 days ago
We use a thing called Relay (https://relay.dev/) to manage our querying, mutating, and state management.

When you query data, it is cached locally in a shared data store that will automatically trigger re-renders of components that take in the data types as a dependency.

You don’t have to write an update to the data, you query it and Relay updates all the underlying models in the local state cache.

The data types are correlated to your components via GraphQL fragments which allows Relay to know what and when to update.

Because most of the values you are using in your component are already stateful, you end up using A LOT less hooks since most state updates will trigger and happen for you.

It’s incredibly powerful once you get going with it.

The downside is getting it to work properly with the type generation. It can be rather finicky and Facebook likes to rewrite the API out from under you every couple years.