Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: refactor code related to unsubscribing global listeners #1451

Merged
merged 1 commit into from Sep 13, 2021

Conversation

shuding
Copy link
Member

@shuding shuding commented Sep 12, 2021

  • Fix typo (unscubscibe)
  • unsubscribe is always a function so no need to check again
  • Other tweaks

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bd68f3f:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

@@ -80,6 +80,6 @@ export const initCache = <Data = any>(
// We might want to inject an extra layer on top of `provider` in the future,
// such as key serialization, auto GC, etc.
// For now, it's just a `Map` interface without any modifications.
return [provider, mutate, unscubscibe]
return [provider, mutate, unsubscribe]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch 😂 thx

@huozhi huozhi merged commit a9c6d79 into master Sep 13, 2021
@huozhi huozhi deleted the optimize-4 branch September 13, 2021 07:01
kodiakhq bot pushed a commit to vercel/turbo that referenced this pull request Sep 8, 2022
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [swr](https://swr.vercel.app) ([source](https://togithub.com/vercel/swr)) | [`1.0.1` -> `1.3.0`](https://renovatebot.com/diffs/npm/swr/1.0.1/1.3.0) | [![age](https://badges.renovateapi.com/packages/npm/swr/1.3.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/swr/1.3.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/swr/1.3.0/compatibility-slim/1.0.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/swr/1.3.0/confidence-slim/1.0.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>vercel/swr</summary>

### [`v1.3.0`](https://togithub.com/vercel/swr/releases/tag/1.3.0)

[Compare Source](https://togithub.com/vercel/swr/compare/1.2.2...1.3.0)

#### What's Changed

-   type: fix type error on SWRConfig by [@&#8203;Himself65](https://togithub.com/Himself65) in [#&#8203;1913](https://togithub.com/vercel/swr/issues/1913)
-   chore: update React 18 dependencies by [@&#8203;shuding](https://togithub.com/shuding) in [#&#8203;1824](https://togithub.com/vercel/swr/issues/1824)
-   test: fix an act warning by [@&#8203;koba04](https://togithub.com/koba04) in [#&#8203;1888](https://togithub.com/vercel/swr/issues/1888)
-   feat: support functional optimisticData by [@&#8203;huozhi](https://togithub.com/huozhi) in [#&#8203;1861](https://togithub.com/vercel/swr/issues/1861)
-   bugfix: make suspense and revalidateIfStale work together by [@&#8203;simowe](https://togithub.com/simowe) in [#&#8203;1851](https://togithub.com/vercel/swr/issues/1851)

**Full Changelog**: vercel/swr@1.2.2...1.3.0

### [`v1.2.2`](https://togithub.com/vercel/swr/releases/tag/1.2.2)

[Compare Source](https://togithub.com/vercel/swr/compare/1.2.1...1.2.2)

#### Highlights of This Release

##### `populateCache` Option Now Supports Function

We added better Optimistic UI support in [v1.2.0](https://togithub.com/vercel/swr/releases/tag/1.2.0). However, what if your API is only returning a subset of the data (such as the mutated part), that can be populated into the cache? Usually, an extra revalidation after that mutation is needed. But now you can also use a function as `populateCache` to transform the mutate result into the full data:

```js
await mutate(addTodo(newTodo), {
  optimisticData: [...data, newTodo],
  rollbackOnError: true,
  populateCache: (addedTodo, currentData) => {
    // `addedTodo` is what the API returns. It's not
    // returning a list of all current todos but only
    // the new added one.
    // In this case, we can transform the mutate result
    // together with current data, into the new data
    // that can be updated.
    return [...currentData, addedTodo];
  },
  // Since the API already gives us the updated information,
  // we don't need to revalidate here.
  revalidate: false,
});
```

The new definition:

```ts
populateCache?: boolean | ((mutationResult: any, currentData: Data) => Data)
```

Here is a demo for it: https://codesandbox.io/s/swr-basic-forked-hi9svh

##### Bug Fixes

#### What's Changed

-   refactor: revalidateIfStale has an effect on updates, not only mounting by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1837
-   fix: reset stale unmountedRef in suspense by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1843
-   test: add a test for the behavior of revalidateOnMount when the key has been changed by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1847
-   feat: Support `populateCache` as a function by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1818

**Full Changelog**: vercel/swr@1.2.1...1.2.2

### [`v1.2.1`](https://togithub.com/vercel/swr/releases/tag/1.2.1)

[Compare Source](https://togithub.com/vercel/swr/compare/1.2.0...1.2.1)

#### Highlights of This Release

##### `shouldRetryOnError` accepts a function

Previously [`shouldRetryOnError`](https://swr.vercel.app/docs/error-handling#error-retry) is either true or false. Now it accepts a function that conditionally determines if SWR should retry. Here's a simple example:

```js
const fetcher = url => fetch(url).then(res => {
  // Fetcher throws if the response code is not 2xx.
  if (!res.ok) throw res
  return res.json()
})

useSWR(key, fetcher, {
  shouldRetryOnError: (error) => {
    // We skip retrying if the API is returning 404:
    if (error.status === 404) return false
    return true
  }
})
```

Thanks to [@&#8203;sairajchouhan](https://togithub.com/sairajchouhan) for contributing!

#### What's Changed

-   `shouldRetryOnError` accepts a function that can be used to conditionally stop retrying   by [@&#8203;sairajchouhan](https://togithub.com/sairajchouhan) in [vercel/swr#1816
-   build(deps-dev): bump next from 12.0.8 to 12.0.9 by [@&#8203;dependabot](https://togithub.com/dependabot) in [vercel/swr#1821
-   fix: useSWRInfinite revalidates with revalidateOnMount by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1830

#### New Contributors

-   [@&#8203;sairajchouhan](https://togithub.com/sairajchouhan) made their first contribution in [vercel/swr#1816

**Full Changelog**: vercel/swr@1.2.0...1.2.1

### [`v1.2.0`](https://togithub.com/vercel/swr/releases/tag/1.2.0)

[Compare Source](https://togithub.com/vercel/swr/compare/1.1.2...1.2.0)

#### Highlights of This Release

##### Optimistic Updates with Auto Error Rollback

There are now some new options in `mutate`:

```js
mutate(patchUser(user), {
  optimisticData: user,
  populateCache: true,
  rollbackOnError: true,
  revalidate: true,
})
```

Here the cache will be immediately updated to `user`, the “optimistic value”. And then a request (remote mutation) is started via `patchUser(user)` and the response will be written to the cache. If that request fails, the original result will be rolled back safely so the optimistic value will be gone. And after all those finish, a revalidation will start to fetch the latest value.

This is extremely helpful for building the optimistic UI pattern.

You can do the same for the global `mutate`, just remember to pass the key. Also, the current `mutate` APIs stay unchanged so `mutate(data, false)` works the same.

Here's an example: https://codesandbox.io/s/swr-basic-forked-k5hps.

https://user-images.githubusercontent.com/3676859/151381238-f3aba769-91b6-4bfc-9285-df1b9ef51773.mp4

##### `.mjs` Support

SWR now has `.mjs` exported for bundlers that prefer this format.

This doesn’t break environments that don’t support `.mjs`. An alternative `.esm.js` and CJS bundle are also published.

You can read more about ES modules [here](https://2ality.com/2017/05/es-module-specifiers.html).

#### What's Changed

-   feat: Optimistic mutation with error rollback by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1745
-   fix: Required return type when mutating by [@&#8203;RKatarine](https://togithub.com/RKatarine) in [vercel/swr#1772
-   fix: use the latest reference of fetcher with suspense mode by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1803
-   test: add delay for flaky focus test by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1762
-   test: remove flaky focus test case by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1793
-   test: use [@&#8203;swc/jest](https://togithub.com/swc/jest) by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1790
-   chore: Ignore coverage report by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1744
-   chore: Merge mutation states by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1748
-   chore: Rename CONCURRENT_REQUESTS to FETCH by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1749
-   chore: Merge extra request states in cache by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1752
-   chore: support mjs exports by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1760
-   chore: remove useless react-native field by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1761
-   chore: comment helper by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1757
-   chore: display name in devtool by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1779
-   chore: simplify example development by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1787
-   chore: build: improve watch commands by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1788
-   chore: Update examples and dependencies by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1789
-   chore: zeit -> vercel by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1791
-   chore: Clean up configurations by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1792
-   chore: move community health files to .github dir by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1794
-   chore: Add link to security email directly by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1795

#### New Contributors

-   [@&#8203;RKatarine](https://togithub.com/RKatarine) made their first contribution in [vercel/swr#1772

**Full Changelog**: vercel/swr@1.1.2...1.2.0

### [`v1.1.2`](https://togithub.com/vercel/swr/releases/tag/1.1.2)

[Compare Source](https://togithub.com/vercel/swr/compare/1.1.1...1.1.2)

#### Highlights of This Release

##### Use the Latest Fetcher Function

SWR will now use the latest fetcher function passed to the hook, when sending the request. Previously it uses the initial snapshotted fetcher.

##### Avoid Unnecessary Auto Revalidations

When refocusing on the window with state changes (like clicking a button that changes the SWR key immediately), SWR now avoids revalidations if they're not necessary. Details can be found in [#&#8203;1720](https://togithub.com/vercel/swr/issues/1720).

##### New Types for `useSWRInfinite`

Two types for `useSWRInfinite` are added: `SWRInfinteHook` and `SWRInfinteKeyLoader`. You can use them to type the hook and the `getKey` function.

##### New `populateCache` option for `mutate`

A new option to control if the mutation data should be written to the cache. You can find the details in [#&#8203;1729](https://togithub.com/vercel/swr/issues/1729).

#### What's Changed

-   Make polyfill for `requestAnimationFrame` more robust by [@&#8203;thomaspaulmann](https://togithub.com/thomaspaulmann) in [vercel/swr#1707
-   type(infinite): export SWRInfinteHook and SWRInfiniteKeyLoader from infinite, rename InfiniteFetcher to SWRInfiniteFetcher by [@&#8203;houkanshan](https://togithub.com/houkanshan) in [vercel/swr#1714
-   feat: Ensure auto revalidations are executed after state updates by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1720
-   Add moduleNameMapper to jest by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1724
-   Improve test by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1725
-   feat: Use the latest reference of fetcher by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1727
-   fix: Re-export InfiniteFetcher by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1728
-   feat: Add `populateCache` option to `mutate` by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1729
-   Fix local state sharing example deps by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1737
-   Merge states for concurrent requests by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1741
-   Skip error retrying when document is not active and improve tests by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1742

#### New Contributors

-   [@&#8203;thomaspaulmann](https://togithub.com/thomaspaulmann) made their first contribution in [vercel/swr#1707
-   [@&#8203;houkanshan](https://togithub.com/houkanshan) made their first contribution in [vercel/swr#1714

**Full Changelog**: vercel/swr@1.1.1...1.1.2

### [`v1.1.1`](https://togithub.com/vercel/swr/releases/tag/1.1.1)

[Compare Source](https://togithub.com/vercel/swr/compare/1.1.0...1.1.1)

#### Highlights of This Release

##### Dynamic `refreshInterval`

You can now pass a function as `refreshInterval`, to dynamically return the interval (in millisecond) til the next request, based on the current data:

```typescript
useSWR('key', fetcher, {
  refreshInterval: function (data: Data | undefined) {
    if (!data) return 3000 // Initial request 
    return data.next_update
  }
})
```

If return `0`, polling will be stopped.

#### What's Changed

-   feat: refreshInterval as a function by [@&#8203;Andrewnt219](https://togithub.com/Andrewnt219) in [vercel/swr#1690
-   test: add refreshInterval function returns 0 by [@&#8203;Andrewnt219](https://togithub.com/Andrewnt219) in [vercel/swr#1691
-   fix: If `newData` is deeply to the latest state, broadcast the latest state by [@&#8203;icyJoseph](https://togithub.com/icyJoseph) in [vercel/swr#1697
-   fix: Return `undefined` data if key's falsy under suspense mode by [@&#8203;icyJoseph](https://togithub.com/icyJoseph) in [vercel/swr#1698

#### New Contributors

-   [@&#8203;Andrewnt219](https://togithub.com/Andrewnt219) made their first contribution in [vercel/swr#1690
-   [@&#8203;icyJoseph](https://togithub.com/icyJoseph) made their first contribution in [vercel/swr#1697

**Full Changelog**: vercel/swr@1.1.0...1.1.1

### [`v1.1.0`](https://togithub.com/vercel/swr/releases/tag/1.1.0)

[Compare Source](https://togithub.com/vercel/swr/compare/1.0.1...1.1.0)

#### Highlights for This Release

##### 1. Built-in & stable serialization for SWR keys

```js
useSWR({ query: graphql`...`, variables }, fetcher)
useSWR({ query: graphql`...`, variables }, fetcher)
useSWR({ variables, query: graphql`...` }, fetcher)
// ^all recognized as the same resource
```

For array keys too, it's safe to do the following:

```js
useSWR([ `...`, { variables } ], fetcher)
```

##### 2. `revalidateFirstPage` for `useSWRInfinite`

This is a new added option for `useSWRInfinite` (defaults to `true`), you can use it to control if the first page should be revalidated when changing the size or doing a mutation.

##### 3. Better TypeScript support

-   Key / arguments
-   Conditional / dependent
-   Constant keys
-   Returned data

![image](https://user-images.githubusercontent.com/3676859/144089090-f46f109a-e2bc-465f-8a75-f4932bc2d7dd.png)

#### What's Changed

-   Feature: make return state(data, error and isValidating) readonly by [@&#8203;anirudh1713](https://togithub.com/anirudh1713) in [vercel/swr#1431
-   Stable hash by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1429
-   test: add render utilities and remove TestSWRConfig by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1435
-   Revert "Feature: make return state(data, error and isValidating) readonly" by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1443
-   Fix initial isValidating when isPaused() returns true by [@&#8203;anothertempore](https://togithub.com/anothertempore) in [vercel/swr#1440
-   build: no emit on error by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1446
-   chore: remove unused typings by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1448
-   enhance: provider release handlers by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1449
-   test: refactor use-swr-cache-test by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1442
-   Chore: refactor code related to unsubscribing global listeners by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1451
-   Chore: code refactoring for swr/infinite by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1452
-   test: refactor concurrent rendering tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1457
-   test: refactor config tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1458
-   Revert "feat: add a warning for invalid arguments with suspense mode … by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1460
-   test: refactor mutation tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1459
-   fix: Support IE11 by [@&#8203;amannn](https://togithub.com/amannn) in [vercel/swr#1463
-   test: refactor immutable and infinite hook tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1466
-   chore: Add React 18 to peerDependencies by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1467
-   test: refactor integration and loading tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1473
-   test: refactor key, middlewares, and suspense tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1474
-   test: refactor offline and refresh tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1483
-   build(deps): bump tmpl from 1.0.4 to 1.0.5 by [@&#8203;dependabot](https://togithub.com/dependabot) in [vercel/swr#1484
-   Upgrade typescript to 4.4.3 by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1486
-   chore: Code refactoring by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1482
-   ci: multiple dir type checking by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1492
-   Type useSWR fetcher by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1477
-   chore: Improve project file structure by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1497
-   chore: Refine type interfaces by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1496
-   chore: Upgrade eslint and add local cache by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1499
-   fix: Invalidate the key when mutating without revalidating by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1498
-   example: add ref checking condition by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1504
-   fix: Refactor core revalidate function and fix isValidating state bug by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1493
-   chore: remove duplicate configs by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1507
-   typing: fix-type-generation by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1509
-   chroe: use yalc for local development by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1508
-   chore: Code refactoring by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1521
-   feat: Add new onDiscarded option by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1523
-   fix: Error events should be deduplicated by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1522
-   chore: Output test code coverage by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1511
-   chore: Mark returned states and mutate callback argument as readonly by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1514
-   test: Add tests for reconnect and merge-config by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1530
-   fix: Only trigger the success event if not discarded by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1529
-   chore: Code refactoring by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1533
-   Add revalidateFirstPage option to swr/infinite ([#&#8203;1401](https://togithub.com/vercel/swr/issues/1401)) by [@&#8203;timas130](https://togithub.com/timas130) in [vercel/swr#1538
-   fix: Reusing cache provider by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1539
-   chore: fix ts comments by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1540
-   fix: Ensure mutate accepts undefined as the data by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1515
-   chore: Fix comment and startAt type by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1541
-   chore: Refactor cleanupState by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1544
-   feat: using latest version of `axios` with fetch interceptor by [@&#8203;danestves](https://togithub.com/danestves) in [vercel/swr#1548
-   test: Add test case for mutation deduplication by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1549
-   test: speed up with [@&#8203;swc-node/jest](https://togithub.com/swc-node/jest) by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1569
-   chore: Optimizations by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1578
-   fix react-native issue by [@&#8203;aFINKndreas](https://togithub.com/aFINKndreas) in [vercel/swr#1583
-   fix: Support for functions that return false by [@&#8203;TakahiroHimi](https://togithub.com/TakahiroHimi) in [vercel/swr#1586
-   fix: adds undefined as valid Key type to allow falsy Key or Key() by [@&#8203;morgs32](https://togithub.com/morgs32) in [vercel/swr#1594
-   fix: can't find variable removeEventListener by [@&#8203;zhaomengfan](https://togithub.com/zhaomengfan) in [vercel/swr#1595
-   Revert "chore: Mark returned states and mutate callback argument as readonly" by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1570
-   fix: change config alteration process in withMiddleware to be immutable by [@&#8203;junsushin-dev](https://togithub.com/junsushin-dev) in [vercel/swr#1556
-   fix: Allow empty mutate argument list for infinite by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1602
-   chore: Add `type: "module"` and use `.mjs` extension by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1604
-   Revert "chore: Add type: "module" and use .mjs extension ([#&#8203;1604](https://togithub.com/vercel/swr/issues/1604))" by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1618
-   enhance: bind removeEventListener by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1596
-   fix: typos by [@&#8203;nguyenyou](https://togithub.com/nguyenyou) in [vercel/swr#1647
-   build: output without minification by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1650
-   Tweak types by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1640
-   fix: supports ssr in ie11([#&#8203;1657](https://togithub.com/vercel/swr/issues/1657)) by [@&#8203;Sh031224](https://togithub.com/Sh031224) in [vercel/swr#1659
-   type: disbale inference when data generic is provided by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1658
-   chore: rename major branch to main by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1664
-   fix keyloader index and previousPageData type by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1669
-   Add defaults for SWRResponse by [@&#8203;TakahiroHimi](https://togithub.com/TakahiroHimi) in [vercel/swr#1609
-   example: update typescript examples with strict ts mode by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1673
-   chore: upgrade eslint to v8 and prettier to v2 by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1674
-   fix: remove unnecessary async by [@&#8203;Cut0](https://togithub.com/Cut0) in [vercel/swr#1676
-   types: remove duplicated typing def by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1675
-   chore: Add test case for `getKey` in `useSWRInfinite` by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1681

#### New Contributors

-   [@&#8203;willheslam](https://togithub.com/willheslam) made their first contribution in [vercel/swr#1393
-   [@&#8203;louisgv](https://togithub.com/louisgv) made their first contribution in [vercel/swr#1406
-   [@&#8203;origin-master](https://togithub.com/origin-master) made their first contribution in [vercel/swr#1409
-   [@&#8203;anirudh1713](https://togithub.com/anirudh1713) made their first contribution in [vercel/swr#1431
-   [@&#8203;amannn](https://togithub.com/amannn) made their first contribution in [vercel/swr#1463
-   [@&#8203;timas130](https://togithub.com/timas130) made their first contribution in [vercel/swr#1538
-   [@&#8203;danestves](https://togithub.com/danestves) made their first contribution in [vercel/swr#1548
-   [@&#8203;aFINKndreas](https://togithub.com/aFINKndreas) made their first contribution in [vercel/swr#1583
-   [@&#8203;TakahiroHimi](https://togithub.com/TakahiroHimi) made their first contribution in [vercel/swr#1586
-   [@&#8203;zhaomengfan](https://togithub.com/zhaomengfan) made their first contribution in [vercel/swr#1595
-   [@&#8203;junsushin-dev](https://togithub.com/junsushin-dev) made their first contribution in [vercel/swr#1556
-   [@&#8203;nguyenyou](https://togithub.com/nguyenyou) made their first contribution in [vercel/swr#1647
-   [@&#8203;Sh031224](https://togithub.com/Sh031224) made their first contribution in [vercel/swr#1659
-   [@&#8203;Cut0](https://togithub.com/Cut0) made their first contribution in [vercel/swr#1676

**Full Changelog**: vercel/swr@1.0.1...1.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/vercel/turborepo).
dutterbutter pushed a commit to dutterbutter/docs-turbo that referenced this pull request Nov 1, 2022
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [swr](https://swr.vercel.app) ([source](https://togithub.com/vercel/swr)) | [`1.0.1` -> `1.3.0`](https://renovatebot.com/diffs/npm/swr/1.0.1/1.3.0) | [![age](https://badges.renovateapi.com/packages/npm/swr/1.3.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/swr/1.3.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/swr/1.3.0/compatibility-slim/1.0.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/swr/1.3.0/confidence-slim/1.0.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>vercel/swr</summary>

### [`v1.3.0`](https://togithub.com/vercel/swr/releases/tag/1.3.0)

[Compare Source](https://togithub.com/vercel/swr/compare/1.2.2...1.3.0)

#### What's Changed

-   type: fix type error on SWRConfig by [@&#8203;Himself65](https://togithub.com/Himself65) in [#&#8203;1913](https://togithub.com/vercel/swr/issues/1913)
-   chore: update React 18 dependencies by [@&#8203;shuding](https://togithub.com/shuding) in [#&#8203;1824](https://togithub.com/vercel/swr/issues/1824)
-   test: fix an act warning by [@&#8203;koba04](https://togithub.com/koba04) in [#&#8203;1888](https://togithub.com/vercel/swr/issues/1888)
-   feat: support functional optimisticData by [@&#8203;huozhi](https://togithub.com/huozhi) in [#&#8203;1861](https://togithub.com/vercel/swr/issues/1861)
-   bugfix: make suspense and revalidateIfStale work together by [@&#8203;simowe](https://togithub.com/simowe) in [#&#8203;1851](https://togithub.com/vercel/swr/issues/1851)

**Full Changelog**: vercel/swr@1.2.2...1.3.0

### [`v1.2.2`](https://togithub.com/vercel/swr/releases/tag/1.2.2)

[Compare Source](https://togithub.com/vercel/swr/compare/1.2.1...1.2.2)

#### Highlights of This Release

##### `populateCache` Option Now Supports Function

We added better Optimistic UI support in [v1.2.0](https://togithub.com/vercel/swr/releases/tag/1.2.0). However, what if your API is only returning a subset of the data (such as the mutated part), that can be populated into the cache? Usually, an extra revalidation after that mutation is needed. But now you can also use a function as `populateCache` to transform the mutate result into the full data:

```js
await mutate(addTodo(newTodo), {
  optimisticData: [...data, newTodo],
  rollbackOnError: true,
  populateCache: (addedTodo, currentData) => {
    // `addedTodo` is what the API returns. It's not
    // returning a list of all current todos but only
    // the new added one.
    // In this case, we can transform the mutate result
    // together with current data, into the new data
    // that can be updated.
    return [...currentData, addedTodo];
  },
  // Since the API already gives us the updated information,
  // we don't need to revalidate here.
  revalidate: false,
});
```

The new definition:

```ts
populateCache?: boolean | ((mutationResult: any, currentData: Data) => Data)
```

Here is a demo for it: https://codesandbox.io/s/swr-basic-forked-hi9svh

##### Bug Fixes

#### What's Changed

-   refactor: revalidateIfStale has an effect on updates, not only mounting by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1837
-   fix: reset stale unmountedRef in suspense by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1843
-   test: add a test for the behavior of revalidateOnMount when the key has been changed by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1847
-   feat: Support `populateCache` as a function by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1818

**Full Changelog**: vercel/swr@1.2.1...1.2.2

### [`v1.2.1`](https://togithub.com/vercel/swr/releases/tag/1.2.1)

[Compare Source](https://togithub.com/vercel/swr/compare/1.2.0...1.2.1)

#### Highlights of This Release

##### `shouldRetryOnError` accepts a function

Previously [`shouldRetryOnError`](https://swr.vercel.app/docs/error-handling#error-retry) is either true or false. Now it accepts a function that conditionally determines if SWR should retry. Here's a simple example:

```js
const fetcher = url => fetch(url).then(res => {
  // Fetcher throws if the response code is not 2xx.
  if (!res.ok) throw res
  return res.json()
})

useSWR(key, fetcher, {
  shouldRetryOnError: (error) => {
    // We skip retrying if the API is returning 404:
    if (error.status === 404) return false
    return true
  }
})
```

Thanks to [@&#8203;sairajchouhan](https://togithub.com/sairajchouhan) for contributing!

#### What's Changed

-   `shouldRetryOnError` accepts a function that can be used to conditionally stop retrying   by [@&#8203;sairajchouhan](https://togithub.com/sairajchouhan) in [vercel/swr#1816
-   build(deps-dev): bump next from 12.0.8 to 12.0.9 by [@&#8203;dependabot](https://togithub.com/dependabot) in [vercel/swr#1821
-   fix: useSWRInfinite revalidates with revalidateOnMount by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1830

#### New Contributors

-   [@&#8203;sairajchouhan](https://togithub.com/sairajchouhan) made their first contribution in [vercel/swr#1816

**Full Changelog**: vercel/swr@1.2.0...1.2.1

### [`v1.2.0`](https://togithub.com/vercel/swr/releases/tag/1.2.0)

[Compare Source](https://togithub.com/vercel/swr/compare/1.1.2...1.2.0)

#### Highlights of This Release

##### Optimistic Updates with Auto Error Rollback

There are now some new options in `mutate`:

```js
mutate(patchUser(user), {
  optimisticData: user,
  populateCache: true,
  rollbackOnError: true,
  revalidate: true,
})
```

Here the cache will be immediately updated to `user`, the “optimistic value”. And then a request (remote mutation) is started via `patchUser(user)` and the response will be written to the cache. If that request fails, the original result will be rolled back safely so the optimistic value will be gone. And after all those finish, a revalidation will start to fetch the latest value.

This is extremely helpful for building the optimistic UI pattern.

You can do the same for the global `mutate`, just remember to pass the key. Also, the current `mutate` APIs stay unchanged so `mutate(data, false)` works the same.

Here's an example: https://codesandbox.io/s/swr-basic-forked-k5hps.

https://user-images.githubusercontent.com/3676859/151381238-f3aba769-91b6-4bfc-9285-df1b9ef51773.mp4

##### `.mjs` Support

SWR now has `.mjs` exported for bundlers that prefer this format.

This doesn’t break environments that don’t support `.mjs`. An alternative `.esm.js` and CJS bundle are also published.

You can read more about ES modules [here](https://2ality.com/2017/05/es-module-specifiers.html).

#### What's Changed

-   feat: Optimistic mutation with error rollback by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1745
-   fix: Required return type when mutating by [@&#8203;RKatarine](https://togithub.com/RKatarine) in [vercel/swr#1772
-   fix: use the latest reference of fetcher with suspense mode by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1803
-   test: add delay for flaky focus test by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1762
-   test: remove flaky focus test case by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1793
-   test: use [@&#8203;swc/jest](https://togithub.com/swc/jest) by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1790
-   chore: Ignore coverage report by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1744
-   chore: Merge mutation states by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1748
-   chore: Rename CONCURRENT_REQUESTS to FETCH by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1749
-   chore: Merge extra request states in cache by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1752
-   chore: support mjs exports by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1760
-   chore: remove useless react-native field by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1761
-   chore: comment helper by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1757
-   chore: display name in devtool by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1779
-   chore: simplify example development by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1787
-   chore: build: improve watch commands by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1788
-   chore: Update examples and dependencies by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1789
-   chore: zeit -> vercel by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1791
-   chore: Clean up configurations by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1792
-   chore: move community health files to .github dir by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1794
-   chore: Add link to security email directly by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1795

#### New Contributors

-   [@&#8203;RKatarine](https://togithub.com/RKatarine) made their first contribution in [vercel/swr#1772

**Full Changelog**: vercel/swr@1.1.2...1.2.0

### [`v1.1.2`](https://togithub.com/vercel/swr/releases/tag/1.1.2)

[Compare Source](https://togithub.com/vercel/swr/compare/1.1.1...1.1.2)

#### Highlights of This Release

##### Use the Latest Fetcher Function

SWR will now use the latest fetcher function passed to the hook, when sending the request. Previously it uses the initial snapshotted fetcher.

##### Avoid Unnecessary Auto Revalidations

When refocusing on the window with state changes (like clicking a button that changes the SWR key immediately), SWR now avoids revalidations if they're not necessary. Details can be found in [#&#8203;1720](https://togithub.com/vercel/swr/issues/1720).

##### New Types for `useSWRInfinite`

Two types for `useSWRInfinite` are added: `SWRInfinteHook` and `SWRInfinteKeyLoader`. You can use them to type the hook and the `getKey` function.

##### New `populateCache` option for `mutate`

A new option to control if the mutation data should be written to the cache. You can find the details in [#&#8203;1729](https://togithub.com/vercel/swr/issues/1729).

#### What's Changed

-   Make polyfill for `requestAnimationFrame` more robust by [@&#8203;thomaspaulmann](https://togithub.com/thomaspaulmann) in [vercel/swr#1707
-   type(infinite): export SWRInfinteHook and SWRInfiniteKeyLoader from infinite, rename InfiniteFetcher to SWRInfiniteFetcher by [@&#8203;houkanshan](https://togithub.com/houkanshan) in [vercel/swr#1714
-   feat: Ensure auto revalidations are executed after state updates by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1720
-   Add moduleNameMapper to jest by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1724
-   Improve test by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1725
-   feat: Use the latest reference of fetcher by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1727
-   fix: Re-export InfiniteFetcher by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1728
-   feat: Add `populateCache` option to `mutate` by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1729
-   Fix local state sharing example deps by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1737
-   Merge states for concurrent requests by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1741
-   Skip error retrying when document is not active and improve tests by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1742

#### New Contributors

-   [@&#8203;thomaspaulmann](https://togithub.com/thomaspaulmann) made their first contribution in [vercel/swr#1707
-   [@&#8203;houkanshan](https://togithub.com/houkanshan) made their first contribution in [vercel/swr#1714

**Full Changelog**: vercel/swr@1.1.1...1.1.2

### [`v1.1.1`](https://togithub.com/vercel/swr/releases/tag/1.1.1)

[Compare Source](https://togithub.com/vercel/swr/compare/1.1.0...1.1.1)

#### Highlights of This Release

##### Dynamic `refreshInterval`

You can now pass a function as `refreshInterval`, to dynamically return the interval (in millisecond) til the next request, based on the current data:

```typescript
useSWR('key', fetcher, {
  refreshInterval: function (data: Data | undefined) {
    if (!data) return 3000 // Initial request 
    return data.next_update
  }
})
```

If return `0`, polling will be stopped.

#### What's Changed

-   feat: refreshInterval as a function by [@&#8203;Andrewnt219](https://togithub.com/Andrewnt219) in [vercel/swr#1690
-   test: add refreshInterval function returns 0 by [@&#8203;Andrewnt219](https://togithub.com/Andrewnt219) in [vercel/swr#1691
-   fix: If `newData` is deeply to the latest state, broadcast the latest state by [@&#8203;icyJoseph](https://togithub.com/icyJoseph) in [vercel/swr#1697
-   fix: Return `undefined` data if key's falsy under suspense mode by [@&#8203;icyJoseph](https://togithub.com/icyJoseph) in [vercel/swr#1698

#### New Contributors

-   [@&#8203;Andrewnt219](https://togithub.com/Andrewnt219) made their first contribution in [vercel/swr#1690
-   [@&#8203;icyJoseph](https://togithub.com/icyJoseph) made their first contribution in [vercel/swr#1697

**Full Changelog**: vercel/swr@1.1.0...1.1.1

### [`v1.1.0`](https://togithub.com/vercel/swr/releases/tag/1.1.0)

[Compare Source](https://togithub.com/vercel/swr/compare/1.0.1...1.1.0)

#### Highlights for This Release

##### 1. Built-in & stable serialization for SWR keys

```js
useSWR({ query: graphql`...`, variables }, fetcher)
useSWR({ query: graphql`...`, variables }, fetcher)
useSWR({ variables, query: graphql`...` }, fetcher)
// ^all recognized as the same resource
```

For array keys too, it's safe to do the following:

```js
useSWR([ `...`, { variables } ], fetcher)
```

##### 2. `revalidateFirstPage` for `useSWRInfinite`

This is a new added option for `useSWRInfinite` (defaults to `true`), you can use it to control if the first page should be revalidated when changing the size or doing a mutation.

##### 3. Better TypeScript support

-   Key / arguments
-   Conditional / dependent
-   Constant keys
-   Returned data

![image](https://user-images.githubusercontent.com/3676859/144089090-f46f109a-e2bc-465f-8a75-f4932bc2d7dd.png)

#### What's Changed

-   Feature: make return state(data, error and isValidating) readonly by [@&#8203;anirudh1713](https://togithub.com/anirudh1713) in [vercel/swr#1431
-   Stable hash by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1429
-   test: add render utilities and remove TestSWRConfig by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1435
-   Revert "Feature: make return state(data, error and isValidating) readonly" by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1443
-   Fix initial isValidating when isPaused() returns true by [@&#8203;anothertempore](https://togithub.com/anothertempore) in [vercel/swr#1440
-   build: no emit on error by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1446
-   chore: remove unused typings by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1448
-   enhance: provider release handlers by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1449
-   test: refactor use-swr-cache-test by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1442
-   Chore: refactor code related to unsubscribing global listeners by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1451
-   Chore: code refactoring for swr/infinite by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1452
-   test: refactor concurrent rendering tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1457
-   test: refactor config tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1458
-   Revert "feat: add a warning for invalid arguments with suspense mode … by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1460
-   test: refactor mutation tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1459
-   fix: Support IE11 by [@&#8203;amannn](https://togithub.com/amannn) in [vercel/swr#1463
-   test: refactor immutable and infinite hook tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1466
-   chore: Add React 18 to peerDependencies by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1467
-   test: refactor integration and loading tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1473
-   test: refactor key, middlewares, and suspense tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1474
-   test: refactor offline and refresh tests by [@&#8203;koba04](https://togithub.com/koba04) in [vercel/swr#1483
-   build(deps): bump tmpl from 1.0.4 to 1.0.5 by [@&#8203;dependabot](https://togithub.com/dependabot) in [vercel/swr#1484
-   Upgrade typescript to 4.4.3 by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1486
-   chore: Code refactoring by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1482
-   ci: multiple dir type checking by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1492
-   Type useSWR fetcher by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1477
-   chore: Improve project file structure by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1497
-   chore: Refine type interfaces by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1496
-   chore: Upgrade eslint and add local cache by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1499
-   fix: Invalidate the key when mutating without revalidating by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1498
-   example: add ref checking condition by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1504
-   fix: Refactor core revalidate function and fix isValidating state bug by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1493
-   chore: remove duplicate configs by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1507
-   typing: fix-type-generation by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1509
-   chroe: use yalc for local development by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1508
-   chore: Code refactoring by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1521
-   feat: Add new onDiscarded option by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1523
-   fix: Error events should be deduplicated by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1522
-   chore: Output test code coverage by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1511
-   chore: Mark returned states and mutate callback argument as readonly by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1514
-   test: Add tests for reconnect and merge-config by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1530
-   fix: Only trigger the success event if not discarded by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1529
-   chore: Code refactoring by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1533
-   Add revalidateFirstPage option to swr/infinite ([#&#8203;1401](https://togithub.com/vercel/swr/issues/1401)) by [@&#8203;timas130](https://togithub.com/timas130) in [vercel/swr#1538
-   fix: Reusing cache provider by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1539
-   chore: fix ts comments by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1540
-   fix: Ensure mutate accepts undefined as the data by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1515
-   chore: Fix comment and startAt type by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1541
-   chore: Refactor cleanupState by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1544
-   feat: using latest version of `axios` with fetch interceptor by [@&#8203;danestves](https://togithub.com/danestves) in [vercel/swr#1548
-   test: Add test case for mutation deduplication by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1549
-   test: speed up with [@&#8203;swc-node/jest](https://togithub.com/swc-node/jest) by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1569
-   chore: Optimizations by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1578
-   fix react-native issue by [@&#8203;aFINKndreas](https://togithub.com/aFINKndreas) in [vercel/swr#1583
-   fix: Support for functions that return false by [@&#8203;TakahiroHimi](https://togithub.com/TakahiroHimi) in [vercel/swr#1586
-   fix: adds undefined as valid Key type to allow falsy Key or Key() by [@&#8203;morgs32](https://togithub.com/morgs32) in [vercel/swr#1594
-   fix: can't find variable removeEventListener by [@&#8203;zhaomengfan](https://togithub.com/zhaomengfan) in [vercel/swr#1595
-   Revert "chore: Mark returned states and mutate callback argument as readonly" by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1570
-   fix: change config alteration process in withMiddleware to be immutable by [@&#8203;junsushin-dev](https://togithub.com/junsushin-dev) in [vercel/swr#1556
-   fix: Allow empty mutate argument list for infinite by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1602
-   chore: Add `type: "module"` and use `.mjs` extension by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1604
-   Revert "chore: Add type: "module" and use .mjs extension ([#&#8203;1604](https://togithub.com/vercel/swr/issues/1604))" by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1618
-   enhance: bind removeEventListener by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1596
-   fix: typos by [@&#8203;nguyenyou](https://togithub.com/nguyenyou) in [vercel/swr#1647
-   build: output without minification by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1650
-   Tweak types by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1640
-   fix: supports ssr in ie11([#&#8203;1657](https://togithub.com/vercel/swr/issues/1657)) by [@&#8203;Sh031224](https://togithub.com/Sh031224) in [vercel/swr#1659
-   type: disbale inference when data generic is provided by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1658
-   chore: rename major branch to main by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1664
-   fix keyloader index and previousPageData type by [@&#8203;promer94](https://togithub.com/promer94) in [vercel/swr#1669
-   Add defaults for SWRResponse by [@&#8203;TakahiroHimi](https://togithub.com/TakahiroHimi) in [vercel/swr#1609
-   example: update typescript examples with strict ts mode by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1673
-   chore: upgrade eslint to v8 and prettier to v2 by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1674
-   fix: remove unnecessary async by [@&#8203;Cut0](https://togithub.com/Cut0) in [vercel/swr#1676
-   types: remove duplicated typing def by [@&#8203;huozhi](https://togithub.com/huozhi) in [vercel/swr#1675
-   chore: Add test case for `getKey` in `useSWRInfinite` by [@&#8203;shuding](https://togithub.com/shuding) in [vercel/swr#1681

#### New Contributors

-   [@&#8203;willheslam](https://togithub.com/willheslam) made their first contribution in [vercel/swr#1393
-   [@&#8203;louisgv](https://togithub.com/louisgv) made their first contribution in [vercel/swr#1406
-   [@&#8203;origin-master](https://togithub.com/origin-master) made their first contribution in [vercel/swr#1409
-   [@&#8203;anirudh1713](https://togithub.com/anirudh1713) made their first contribution in [vercel/swr#1431
-   [@&#8203;amannn](https://togithub.com/amannn) made their first contribution in [vercel/swr#1463
-   [@&#8203;timas130](https://togithub.com/timas130) made their first contribution in [vercel/swr#1538
-   [@&#8203;danestves](https://togithub.com/danestves) made their first contribution in [vercel/swr#1548
-   [@&#8203;aFINKndreas](https://togithub.com/aFINKndreas) made their first contribution in [vercel/swr#1583
-   [@&#8203;TakahiroHimi](https://togithub.com/TakahiroHimi) made their first contribution in [vercel/swr#1586
-   [@&#8203;zhaomengfan](https://togithub.com/zhaomengfan) made their first contribution in [vercel/swr#1595
-   [@&#8203;junsushin-dev](https://togithub.com/junsushin-dev) made their first contribution in [vercel/swr#1556
-   [@&#8203;nguyenyou](https://togithub.com/nguyenyou) made their first contribution in [vercel/swr#1647
-   [@&#8203;Sh031224](https://togithub.com/Sh031224) made their first contribution in [vercel/swr#1659
-   [@&#8203;Cut0](https://togithub.com/Cut0) made their first contribution in [vercel/swr#1676

**Full Changelog**: vercel/swr@1.0.1...1.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/vercel/turborepo).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants