New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-fetch-tools

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-fetch-tools

React hooks for managing http request state

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

fetch-tools

A tiny collection of react hooks to manage your http request state.

Installation

npm

npm install react-fetch-tools

yarn

yarn add react-fetch-tools

bun

bun add react-fetch-tools

How to use?

This package comes with two react hooks (planning to add more).

  • useMutation : mutation can be used whenever you are trying to change something on the remote data source, like using http methods such as POST PUT or DELETE

example:

import StarsListCollection from "@/database/schemas/star-list";

import { useMutation } from "react-fetch-tools";

export function useCreateListMutation() {
	return useMutation(async function createList({
		title,
		description,
	}: {
		title: string;
		description?: string;
	}) {
		await StarsListCollection.create({
			title,
			description,
			reposCount: 0,
		});
	});
}

  • useQuery : This hooks can be used whenever you are trying query remote data source, like using http method GET
import StarsListCollection from "@/database/schemas/star-list";

import { useQuery } from "react-fetch-tools";

export function useGetStarLists() {
	return useQuery(async () => {
		const res = await StarsListCollection.findAll();
		return res;
	});
}

contributions

Contributing

Here's how you can contribute:

  • Open an issue if you believe you've encountered a bug.
  • Make a pull request to add new features/make quality-of-life improvements/fix bugs.

License

Licensed under the Apache-2.0 license.

FAQs

Package last updated on 16 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts