Update SWR's Cache with a Server-side Response
lessonDuration 3m 48sFree
We can use the `mutate()` hook again to update our client-side cache using the canonical ID from the server response.
Browse
Find courses, lessons, articles, talks, and podcasts.
29 resources
Showing 25–29 · Page 2 of 2
lessonDuration 3m 48sFree
We can use the `mutate()` hook again to update our client-side cache using the canonical ID from the server response.
lessonDuration 3m 11sFree
Learn how to use the `mutate` function returned from `useSwr(key)` to update the client-side cache's value for the given cache key.
lessonDuration 1m 21sFree
The Optional Chaining Operator, `?.`, can be used as a simple way to check if a variable has a _nullish_ value (`null` or `undefined`). Instead of littering your app with checks like `data && data.movies`, you can write `data?.movies` instead. Check out the [Optional chaining MDN docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) to read more about the new operator.
lessonDuration 4m 29sFree
Mirage JS lets you mock out production APIs directly alongside your frontend React code. You can tweak the data or force a network request to hang, so you can quickly design different states of your application. In this way Mirage lets you build every state of your UI regardless of the state of your production API. Check out [Mirage's React quickstart here](https://miragejs.com/quickstarts/react/develop-a-component).
course
Vercel's data-fetching library SWR features a client-side cache. Learn how to use the mutate hook to manipulate this cache in order to optimistically update your UI without waiting for a response from the network. Learn more about SWR here: https://github.com/zeit/swr