Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Deps: Update dependency swr to v2. - autoclosed #188

Closed
wants to merge 1 commit into from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Aug 6, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
swr (source) 0.5.7 -> 2.2.4 age adoption passing confidence

Release Notes

vercel/swr (swr)

v2.2.4

Compare Source

Patches

Full Changelog: vercel/swr@v2.2.3...v2.2.4

v2.2.3

Compare Source

v2.2.2

Compare Source

What's Changed

New Contributors

Full Changelog: vercel/swr@v2.2.1...v2.2.2

v2.2.1

Compare Source

What's Changed

New Contributors

Full Changelog: vercel/swr@v2.2.0...v2.2.1

v2.2.0

Compare Source

What's Changed

New Contributors

Full Changelog: vercel/swr@v2.1.5...v2.2.0

v2.1.5

Compare Source

What's Changed

Full Changelog: vercel/swr@v2.1.4...v2.1.5

v2.1.4

Compare Source

What's Changed

New Contributors

Full Changelog: vercel/swr@v2.1.3...v2.1.4

v2.1.3

Compare Source

What's Changed

New Contributors

Full Changelog: vercel/swr@v2.1.2...v2.1.3

v2.1.2

Compare Source

Patches
  • Improved type inferring for swr/subscription
  • Adding SWRSubscriptionOptions type for swr/subscription
Changes
New Contributors

Full Changelog: vercel/swr@v2.1.1...v2.1.2

v2.1.1

Compare Source

Patches

Documentation

New Contributors

Full Changelog: vercel/swr@v2.1.0...v2.1.1

v2.1.0

Compare Source

v2.0.4

Compare Source

Patches
Misc
New Contributors

Full Changelog: vercel/swr@v2.0.3...v2.0.4

v2.0.3

Compare Source

Patches

Chores

New Contributors

Full Changelog: vercel/swr@v2.0.2...v2.0.3

v2.0.2

Compare Source

Patches

Chores

Full Changelog: vercel/swr@v2.0.1...v2.0.2

v2.0.1

Compare Source

In this patch release, we majorly improved typing support and SWR can infer the types based on the configuration.

  • When the suspense option is true, the returned data will exclude undefined and the isLoading will always be false.
  • When the fallbackData option is provided, the returned data will be the same type of fallbackData, and the isLoading will always be false.

Here's a demo for it:

swr-2.0.1.mp4

What's Changed

New Contributors

Full Changelog: vercel/swr@2.0.0...v2.0.1

v2.0.0

Compare Source

Announcing SWR 2.0

We are excited to announce the release of SWR 2.0! The new version comes with a lot of improvements:

  • New useSWRMutation hook
  • Enhanced mutation and optimistic UI capabilities
  • SWR DevTools
  • Preload resource
  • Improved React 18 support

And more!

Read our blog post and migration guide: https://swr.vercel.app/blog/swr-v2

What's Changed

New Contributors

Full Changelog: vercel/swr@1.2.2...2.0.0

v1.3.0

Compare Source

What's Changed

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

v1.2.2

Compare Source

Highlights of This Release

populateCache Option Now Supports Function

We added better Optimistic UI support in v1.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:

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:

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

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

v1.2.1

Compare Source

Highlights of This Release

shouldRetryOnError accepts a function

Previously shouldRetryOnError is either true or false. Now it accepts a function that conditionally determines if SWR should retry. Here's a simple example:

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 @​sairajchouhan for contributing!

What's Changed

New Contributors

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

v1.2.0

Compare Source

Highlights of This Release

Optimistic Updates with Auto Error Rollback

There are now some new options in mutate:

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.

CleanShot.2022-01-27.at.15.39.58.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.

What's Changed

New Contributors

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

v1.1.2

Compare Source

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 [#​1720](https://togithub.com/verc


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled because a matching PR was automerged previously.

Rebasing: Whenever PR is behind base branch, 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, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added the Dependency label Aug 6, 2023
@renovate renovate bot force-pushed the renovate/swr-2.x branch 3 times, most recently from 9539414 to 5804c67 Compare October 22, 2023 15:10
@renovate renovate bot changed the title Deps: Update dependency swr to v2. Deps: Update dependency swr to v2. - autoclosed Oct 23, 2023
@renovate renovate bot closed this Oct 23, 2023
@renovate renovate bot deleted the renovate/swr-2.x branch October 23, 2023 01:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants