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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@redux-hooks/request

v1.0.0

Published

React hooks designed for managing requests with Redux

Readme

useRequest

A react hook designed for managing request state with Redux

Installation

redux-hooks requires the following packages:

  1. [email protected] or later
  2. [email protected] or later
  3. [email protected] or later
npm install --save @redux-hooks/request

Getting Started

1. Setup the request reducer

import request from '@redux-hooks/request';

const reducer = combineReducer({
  request,
  // ... and your other reducers
});

export default reducer;

2. Enjoy the hook

import { useRequest } from '@redux-hooks/request';
import React, { useEffect } from 'react';
import TodoList from './TodoList';

function getTodos() {
  return fetch('/todos').then(response => response.json());
}

function Todos() {
  const [result, request] = useRequest('GET_TODOS', getTodos);

  useEffect(() => {
    request();
  }, [request]);

  if (!result.requested || !result.requesting) {
    return 'Loading';
  }

  if (result.error) {
    return result.error;
  }

  return (
    <TodoList todos={result.data}>
  )
}

export default Todos;

API Reference

useRequest

useRequest(
  name: string,
  request: (...args: Args[]) => Promise<Data>,
  cacheKey?: string,
): [
  RequestResult<Data>,
  (...args: Args[]) => Promise<RequestResult<Data>>
];

Arguments

  1. name: string: Name of the request. It must be unique across all requests.

  2. request: (...args: Args[]) => Promise<Data>: The request function. It should return a promise.

  3. cacheKey?: string: The request result will be cached by the provided cache key.

Usage

import { useRequest } from '@redux-hooks/request';
import { useEffect } from 'react';

function getTodo(todoId: string) {
  return fetch(`/todo/${todoId}`).then(response => response.json());
}

function useTodo(todoId: string) {
  const [result, request] = useRequest('TODO', getTodo, todoId);

  useEffect(() => {
    request(todoId);
  }, [request, todoId]);

  return result;
}

export default useTodo;

makeUseRequest

Factory for making the useRequest hook

makeUseRequest({
  baseSelector?: (state: any) => State,
  context?: React.Context,
}): useRequestHook;

Options

  1. baseSelector: (state: any) => State: Required if the request reducer is setup different from the default approach

  2. context: React.Context: Required if multiple stores are set