$ git grep -n "selectIsLoggedIn" | wc -l
80
80 useSelector(selectIsLoggedIn) call sites across 5 federated remotes. Header reads it for the login pill. Cart reads it for the guest-vs-account branch. Checkout reads it for the redirect. Every protected route reads it.
Now imagine the user slice ships a rename: isLoggedIn becomes isAuthenticated. The PATCH bump goes out. Every remote that hasn't redeployed yet starts throwing:
TypeError: Cannot read property 'isLoggedIn' of undefined
80 edits across 5 codebases. Five different teams. One coordinated release window. This is the bug that custom Redux hooks solve.
What the article covers
-
The foundation hooks —
useAppDispatchanduseAppSelectorexported through@myapp/store. Why importinguseSelectordirectly fromreact-reduxsilently breaks the singleton. -
Three legitimate hook shapes: read-only (
useIsLoggedIn), read+write (useCurrentUser,useCart), view-model (useHeaderViewModel— composes 3 slices viacreateSelector). -
Two re-render traps that look correct at code review: selectors defined inside the hook body, hooks returning new object literals without
useMemo. -
Folder layout at
packages/core/store/src/hooks/— flat, one file per hook, every hook re-exported throughindex.js. -
renderHooktesting pattern with a freshmakeStore()per test. The stability test (result.current.loginkeeps same reference across rerenders) catches the #1 silent regression.
Builds directly on top of the slices article — these hooks are the consumer API for the slice patterns from there.
Read the full guide with code examples → https://blog.srinudesetti.in/micro-frontend/state-management/custom-redux-hooks-micro-frontend

Top comments (0)