berzel / senza-frontend

Senza is Zimbabwe largest independent job board
senza.vercel.app
0 stars 0 forks source link

[Snyk] Upgrade swr from 1.0.1 to 1.2.2 #51

Closed BrendonChirume closed 6 months ago

BrendonChirume commented 2 years ago

Snyk has created this PR to upgrade swr from 1.0.1 to 1.2.2.

merge advice As this is a private repository, Snyk-bot does not have access. Therefore, this PR has been created automatically, but appears to have been created by a real user.
:sparkles: Snyk has automatically assigned this pull request, set who gets assigned.

:information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.


Release notes
Package name: swr
  • 1.2.2 - 2022-02-18

    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

    • refactor: revalidateIfStale has an effect on updates, not only mounting by @ koba04 in #1837
    • fix: reset stale unmountedRef in suspense by @ promer94 in #1843
    • test: add a test for the behavior of revalidateOnMount when the key has been changed by @ koba04 in #1847
    • feat: Support populateCache as a function by @ shuding in #1818

    Full Changelog: 1.2.1...1.2.2

  • 1.2.1 - 2022-02-02

    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

    • shouldRetryOnError accepts a function that can be used to conditionally stop retrying by @ sairajchouhan in #1816
    • build(deps-dev): bump next from 12.0.8 to 12.0.9 by @ dependabot in #1821
    • fix: useSWRInfinite revalidates with revalidateOnMount by @ koba04 in #1830

    New Contributors

    Full Changelog: 1.2.0...1.2.1

  • 1.2.1-experimental.0 - 2022-01-29
  • 1.2.0 - 2022-01-26
    Read more
  • 1.2.0-beta.1 - 2022-01-12

    What's Changed

    New Contributors

    Full Changelog: 1.1.2...1.2.0-beta.1

  • 1.2.0-beta.0 - 2021-12-28

    Highlights of This Release

    Dedicated API for Optimistic Updates with Auto Rollback on Error

    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.

    What's Changed

    Full Changelog: 1.1.2...1.2.0-beta.0

  • 1.1.2 - 2021-12-26
    Read more
  • 1.1.2-beta.1 - 2021-12-23
    Read more
  • 1.1.2-beta.0 - 2021-12-15

    What's Changed

    New Contributors

    Full Changelog: 1.1.1...1.1.2-beta.0

  • 1.1.1 - 2021-12-10
    Read more
  • 1.1.0 - 2021-11-30
  • 1.1.0-beta.12 - 2021-11-26
  • 1.1.0-beta.11 - 2021-11-24
  • 1.1.0-beta.10 - 2021-11-23
  • 1.1.0-beta.9 - 2021-11-11
  • 1.1.0-beta.8 - 2021-11-01
  • 1.1.0-beta.7 - 2021-11-01
  • 1.1.0-beta.6 - 2021-10-24
  • 1.1.0-beta.5 - 2021-10-09
  • 1.1.0-beta.4 - 2021-10-03
  • 1.1.0-beta.3 - 2021-10-01
  • 1.1.0-beta.2 - 2021-09-26
  • 1.1.0-beta.1 - 2021-09-22
  • 1.1.0-beta.0 - 2021-09-15
  • 1.0.1 - 2021-09-12
from swr GitHub release notes
Commit messages
Package name: swr
  • f24c621 1.2.2
  • baaafc2 feat: Support `populateCache` as a function (#1818)
  • ef400ea test: add a test for the behavior of revalidateOnMount when the key has been changed (#1847)
  • f98da66 fix: reset stale unmountedRef in suspense (#1843)
  • 01e0594 refactor: revalidateIfStale has an effect on updates, not only mounting (#1837)
  • c63cafc 1.2.1
  • 922048e fix: useSWRInfinite revalidates with revalidateOnMount (#1830)
  • a4ab0c9 build(deps-dev): bump next from 12.0.8 to 12.0.9 (#1821)
  • 53dc100 feat: shouldErrorRetry accepts a function (#1816)
  • bfb9edc 1.2.0
  • e3dc48a fix: use the latest reference of fetcher with suspense mode (#1803)
  • fdd5c33 Add link to security email directly (#1795)
  • 7dfd890 chore: Move community health files to .github (#1794)
  • c9793ac chore: Clean up configurations (#1792)
  • 3a7dd3b test: use @ swc/jest (#1790)
  • 13a8870 test: remove flaky focus test case (#1793)
  • ce74819 chore: Update company name (#1791)
  • 0c4e7ad chore: Update examples and dependencies (#1789)
  • 53f3bef Improve watch commands (#1788)
  • 1cd8b7b simplify example development (#1787)
  • d45b05d 1.2.0-beta.1
  • 3b49c39 polish: display name in devtool (#1779)
  • 72b767f type: Required return type when mutating (#1772)
  • d4f4411 test: add delay for flaky focus test (#1762)
Compare

Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.

For more information:

🧐 View latest project report

👩‍💻 Set who automatically gets assigned

🛠 Adjust upgrade PR settings

🔕 Ignore this dependency or unsubscribe from future upgrade PRs

vercel[bot] commented 2 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/berzel/senza/8VN7TKhFa8MZZuwhkQdRFvsjk88x
✅ Preview: https://senza-git-snyk-upgrade-675d224411e9e2a73ed3654f5b6a4956-berzel.vercel.app