Shared Hook State with SWRMay 09, 2020SWR is a React hook for data fetching that features a cache for requests. This is generally used to share the response from API calls and deduplicate requests, but SWR is flexible enough to support another use case: shared hook state. 1 Let's look at an example of a useUsername hook: const useUsername = () => { return useState('') } const UsernameInput = () =>
![Shared Hook State with SWR](https://cdn-ak-scissors.b.st-hatena.com/image/square/d14a4441e429c423b1d8b94c9d9d30529a5e7532/height=288;version=1;width=512/https%3A%2F%2Fpaco.me%2Ftwitter-sm.png)