State Management · Junior · Question 48 of 75
What are the arguments of useSWR(key, fetcher)?
- ✓Correct answer: A unique key (often the URL) and a function that loads the data
- 2A reducer and an initial state
- 3An HTTP method and a request body
Explanation
const { data, error, isLoading } = useSWR('/api/user', fetcher). The key identifies the cache entry: every component using the same key shares one request and one cached value.