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