What problem does it solve?
Converting React components from Redux + redux-saga data fetching to SWR hooks involves many coordinated changes across reducers, sagas, selectors, connected components, and tests, and missing any step leaves stale store slices or broken selectors behind.
Core Features & Use Cases
- Step-by-step migration workflow: Create SWR hooks with useSwrWithClusterId, convert connected components to hooks, simplify wrapper components, and delete Redux artifacts in the correct order.
- SWR configuration patterns: Guidance on keys, polling via refreshInterval, conditional fetching with null keys or fetchers, immutable data, and cache invalidation after mutations using bound mutate.
- Testing and cleanup guidance: Patterns for mocking SWR hooks with jest.spyOn, testing loading/error/role states, extracting pure functions from selectors, and gradual migration via an SWR-to-Redux bridge.
- Use Case: A developer modernizing a CockroachDB DB Console page replaces a CachedDataReducer, its sagas, and a connect() HOC with a single co-located SWR hook and a functional component, then removes the store registrations and updates tests.
Quick Start
Migrate the schema insights page in cluster-ui from Redux and sagas to SWR hooks following this migration guide.