npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

redux-thunk-wrapper

v1.0.4

Published

A React hook wrapper for Redux Toolkit async thunks with retries, loading, and error handling.

Readme

redux-thunk-wrapper

A reusable React hook to dispatch Redux Toolkit async thunks with built-in loading, retry, and **error handling ** support.


Features

  • Works with createAsyncThunk and custom thunk action creators
  • Supports automatic retries with configurable attempts
  • Optional loading state for UI feedback
  • Centralized error handling callback
  • Fully typed with TypeScript
  • Minimal boilerplate, clean component usage

Installation

npm install redux-thunk-wrapper
# or
yarn add redux-thunk-wrapper

Make sure you have these peer dependencies installed as well:

  • react (>=16.8)
  • react-redux (>=7.1)

Usage

import React, {useEffect} from "react";
import {useThunkWrapper} from "redux-thunk-wrapper";
import {fetchPostsByUser} from "./store/postsSlice";

function UserPosts({userId}: { userId: number }) {
    // Wrap thunk with loading, retry and error handling
    const [fetchPosts, loading] = useThunkWrapper(fetchPostsByUser, {
        withLoading: true,
        retry: 3,
        onError: (error) => alert("Failed to load posts: " + error.message),
    });

    useEffect(() => {
        fetchPosts(userId);
    }, [fetchPosts, userId]);

    if (loading) return <p>Loading...</p>;

    return <div>Posts loaded! {/* Render your posts here */}</div>;
}

API

useThunkWrapper(actionCreator, options?)

  • actionCreator - a Redux thunk action creator (sync or async, supports createAsyncThunk)
  • options (optional):
    • withLoading (boolean): whether to track loading state (default: false)
    • retry (boolean | number):
      • false or omitted: no retry (1 attempt)
      • true: retry once (2 attempts total)
      • number: max retry attempts
    • onError ((error: any) => void): callback when an error occurs

Returns: [runThunk, loading] tuple where:

  • runThunk is an async function that dispatches the thunk with arguments
  • loading is a boolean indicating whether the thunk is in progress (if withLoading is enabled)

Development

  • Clone the repo
  • Run npm install
  • Build with npm run build
  • Run tests (if any)

License

MIT © Jingx


Contributing

Feel free to open issues or PRs. All contributions are welcome!


Author

Jingx – [email protected]