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

react-native-resource-manager

v1.0.0

Published

This document provides the API reference for the hooks in the `resourceManager` system.

Downloads

2

Readme

📦 React Native Resource Manager

A reusable set of React hooks to manage remote data fetching and CRUD operations in a clean, state-synchronized way.

This package provides a unified API to:

  • Fetch paginated data from APIs
  • Manage local and remote create/update/delete operations
  • Normalize and extract data from API responses
  • Handle loading, error, and pagination states

🚀 Installation

Add the hooks folder to your React Native or React project and import from:

import { useResourceManager } from '@/hooks/resource-manager-hooks';

# 🧰 Resource Manager Hooks

This package contains a set of composable React hooks to simplify **fetching**, **mutation**, and **state management** of remote resources. It enables consistent and reusable handling of async data interactions in React (and React Native) apps.

## 🔍 Overview

### Hooks Included:

- **`useFetch`** – Fetch remote data with pagination, loading, and error state management
- **`useMutation`** – Handle local and remote Create, Update, and Delete operations
- **useResourceManager** – Combines `useFetch` and `useMutation` for full data lifecycle management

---

## 🚀 Quick Start

### 1. Installation

This is a local package, so simply import from your project like:

```ts
import { useResourceManager } from '@/hooks/resourceManager';

Make sure your folder structure includes:

resourceManager/
├── useFetch.ts
├── useMutation.ts
├── useResourceManager.ts
├── resourceManager.types.ts
└── index.ts

2. Example Usage

const { state, queries, crud } = useResourceManager({
  serviceFn: fetchUsers,
  dataExtractor: (res) => ({
    data: res.users,
    totalResults: res.totalCount,
    currentPage: res.page,
    totalPages: res.totalPages,
  }),
  remote: {
    insertFn: createUser,
    updateFn: updateUser,
    deleteFn: deleteUser,
  },
});

useEffect(() => {
  queries.fetchData();
}, []);

UI Rendering Example

<FlatList
  data={state.data}
  refreshing={state.isRefreshing}
  onRefresh={queries.refetchData}
  onEndReached={queries.fetchNextPage}
  renderItem={({ item }) => (
    <UserItem user={item} onDelete={() => crud.deleteItem(item.id)} />
  )}
/>

📦 Hook APIs

useFetch({ serviceFn, dataExtractor, onError, shouldFetch })

Returns [state, queries, mutations]

  • state: data, loading states, errors, pagination
  • queries: fetchData, fetchNextPage, refetchData
  • mutations: addNewData, updateExistingData, deleteExistingData, etc.

useMutation({ local, remote })

Returns: addItem, updateItem, deleteItem and mutation status flags

useResourceManager({ serviceFn, dataExtractor, remote, onError, shouldFetch })

Returns:

  • state: from useFetch
  • queries: fetch-related functions
  • crud: mutation functions from useMutation

🛠 Advanced Configuration

You can override:

  • dataExtractor to customize response transformation
  • dataKey in mutations to extract nested created/updated records
  • shouldFetch to delay or prevent automatic fetching

🧼 Best Practices

  • Keep serviceFn and remote functions stable (use useCallback if needed)
  • Provide dataExtractor to handle complex API response formats
  • Combine with context providers if global state is needed

📁 Type Definitions

Types are declared in resourceManager.types.ts and exported for use in components or higher-order abstractions.


📃 License

This is part of the DropIt project. Internal use only.