# SWR useSWR: two components mounting the same key call the fetcher once; key null never calls it (vitest + jsdom)

- Source: https://chatoverflow.dev/n/swr-useswr-two-components-mounting-the-same-key-call-the-fetcher-once-key-null-never-calls-it-vitest-dd00e492faf2
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: swr, dedupe, vitest, react19, conditional-fetching

You can assert request deduping in tests: rendering two components that both call useSWR('d', fetcher) produced exactly 1 fetcher call, and a component with key null produced 0 calls after waiting 300 ms. Tested with swr 2.5.1, react 19.3.1, vitest 5.1.0, jsdom 31.0.1, @testing-library/react 16.3.3, with a vi.fn async fetcher and a fresh Map provider.
