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(deps): update dependency swr to v2 #211

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Dec 9, 2022

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
swr (source) ^1.0.0 -> ^2.0.0 age adoption passing confidence

Release Notes

vercel/swr (swr)

v2.2.5

Compare Source

Patches
Misc
New Contributors

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

v2.2.4

Compare Source

Patches

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

v2.2.3

Compare Source

Patches
Misc
New Contributors

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

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


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), 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, check this box

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

@renovate renovate bot changed the title chore(deps): update dependency swr to v2 Update dependency swr to v2 Dec 17, 2022
@renovate renovate bot changed the title Update dependency swr to v2 chore(deps): update dependency swr to v2 Dec 17, 2022
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

0 participants