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

Update dependency use-debounce to v6 - autoclosed #285

Closed
wants to merge 1 commit into from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Mar 7, 2021

WhiteSource Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
use-debounce 3.4.3 -> 6.0.1 age adoption passing confidence

Release Notes

xnimorz/use-debounce

v6.0.1

Compare Source

v6.0.0

Compare Source

  • breakind change: removed callback field, instead of this useDebouncedCallback and useThrottledCallback returns a callable function:
    Old:

    const { callback, pending } = useDebouncedCallback(/*...*/);
    // ...
    debounced.callback();

    New:

    const debounced = useDebouncedCallback(/*...*/);
    // ...
    debounced();
    /**
     * Also debounced has fields:
     * {
     *   cancel: () => void
     *   flush: () => void
     *   isPending: () => boolean
     * }
     * So you can call debounced.cancel(), debounced.flush(), debounced.isPending()
     */

    It makes easier to understand which cancel \ flush or isPending is called in case you have several debounced functions in your component

  • breaking change: Now useDebounce, useDebouncedCallback and useThrottledCallback has isPending method instead of pending

    Old:

    const { callback, pending } = useDebouncedCallback(/*...*/);

    New:

    const { isPending } = useDebouncedCallback(/*...*/);
    /**
     * {
     *   cancel: () => void
     *   flush: () => void
     *   isPending: () => boolean
     * }
     */
  • get rid of useCallback calls

  • improve internal typing

  • decrease the amount of functions to initialize each useDebouncedCallback call

  • reduce library size:

    Whole library: from 946 B to 899 B === 47 B
    useDebounce: from 844 to 791 === 53 B
    useDebouncedCallback: from 680 to 623 === 57 B
    useThrottledCallback: from 736 to 680 === 56 B

v5.2.1

Compare Source

v5.2.0

Compare Source

  • Added useThrottledCallback

v5.1.0

Compare Source

wait param is optional. If you don't provide a wait argument, use-debounce will postpone a callback with requestAnimationFrame if it's in browser environment, or through setTimeout(..., 0) otherwise.

v5.0.4

Compare Source

  • Add an export for React Native

v5.0.3

Compare Source

v5.0.2

Compare Source

  • Add size-limit and configure it for esm modules. Now the size of the whole library is limited within 1 KB (thanks to @​omgovich)

  • Add an export map to your package.json. (thanks to @​omgovich)

  • Reduce bundle size (thanks to @​omgovich):
    Before:

    esm/index.js
    Size:       908 B with all dependencies, minified and gzipped
    
    esm/index.js
    Size:       873 B with all dependencies, minified and gzipped
    
    esm/index.js
    Size:       755 B with all dependencies, minified and gzipped
    

    Now:

    esm/index.js
    Size:       826 B with all dependencies, minified and gzipped
    
    esm/index.js
    Size:       790 B with all dependencies, minified and gzipped
    
    esm/index.js
    Size:       675 B with all dependencies, minified and gzipped
    
  • Add notes about returned value from debounced.callback and its subsequent calls: https://github.com/xnimorz/use-debounce#returned-value-from-debouncedcallback

  • Add project logo (thanks to @​omgovich): use-debounce

v5.0.1

Compare Source

  • Fix typing to infer correct callback type (thanks to @​lytc)

v5.0.0

Compare Source

  • breaking change: Now useDebouncedCallback returns an object instead of array:

    Old:

    const [debouncedCallback, cancelDebouncedCallback, callPending] = useDebouncedCallback(/*...*/);

    New:

    const debounced = useDebouncedCallback(/*...*/);
    /**
     * debounced: {
     *   callback: (...args: T) => unknown, which is debouncedCallback
     *   cancel: () => void, which is cancelDebouncedCallback
     *   flush: () => void, which is callPending
     *   pending: () => boolean, which is a new function
     * }
     */
  • breaking change: Now useDebounce returns an array of 2 fields instead of a plain array:
    Old:

    const [value, cancel, callPending] = useDebounce(/*...*/);

    New:

    const [value, fn] = useDebounce(/*...*/);
    /**
     * value is just a value without changes
     * But fn now is an object: {
     *   cancel: () => void, which is cancel
     *   flush: () => void, which is callPending
     *   pending: () => boolean, which is a new function
     * }
     */
  • Added pending function to both useDebounce and useDebouncedCallback which shows whether component has pending callbacks
    Example:

    function Component({ text }) {
      const debounced = useDebouncedCallback(useCallback(() => {}, []), 500);
    
      expect(debounced.pending()).toBeFalsy();
      debounced.callback();
      expect(debounced.pending()).toBeTruthy();
      debounced.flush();
      expect(debounced.pending()).toBeFalsy();
    
      return <span>{text}</span>;
    }

For more details of these major changes you could check this commit xnimorz/use-debounce@1b4ac04 and this issue xnimorz/use-debounce#61

  • Fixed security alerts

v4.0.0

Compare Source

  • breaking change: Support lodash style throttling options for trailing+maxWidth. Thanks to @​tryggvigy
    Example:
useDebouncedCallback(callback, 300, {
  leading: true,
  trailing: false,
  maxWait: 300,
});

Where the trailing edge is turned off. Let's say the function is called twice in the first 300ms. Now debounced function to have been called once.

how to migrate: Please, check your traling: false params with maxWait option

  • breaking change: Now in case delay option is unset, it will be requestAnimationFrame delay

  • breaking change: Now debouncedCallback from useDebouncedCallback returns a value. In v3 it used to return undefined:


Configuration

📅 Schedule: 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 WhiteSource Renovate. View repository job log here.

@renovate renovate bot force-pushed the renovate/use-debounce-6.x branch from 8a7e91e to cf2e5e2 Compare April 3, 2021 15:16
@renovate renovate bot changed the title Update dependency use-debounce to v6 Update dependency use-debounce to v6 - autoclosed Jun 20, 2021
@renovate renovate bot closed this Jun 20, 2021
@renovate renovate bot deleted the renovate/use-debounce-6.x branch June 20, 2021 15:51
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.

useDebouncedCallback() has a slightly wrong type
1 participant