useSyncExternalStore - The underrated React API
You might have heard of useSyncExternalStore()
, a new React 18 hook to subscribe to external data sources. It is often used internally by state management libraries - like Redux - to implement a selector system.
But what about using useSyncExternalStore()
in your own application code?
In this interactive article, I want to present you a problem: over-returning React hooks triggering useless re-renders. We will see how useSyncExternalStore()
can be a good fix.