
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
react-query-useful-hooks
Advanced tools
The best and useful hooks for react-query
npm install axios react-query react-query-useful-hooks
axios
andreact-query
is a peer dependency and needs to be installed explicitly
import React from 'react';
import {useFetch} from 'react-query-useful-hooks';
import React from 'react';
import {useFetch} from 'react-query-useful-hooks';
function Todos() {
const {isError, isFetching, data, refetch} = useFetch({
url: 'todos/1',
enabled: true
});
if (isFetching) return <p>Loading...</p>;
if (isError) return <p>Error!</p>;
return (
<div>
<button onClick={() => refetch()}>refetch</button>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}
export default Todos;
The package exports one default export and named exports:
import {
useFetch,
useInfinite,
usePaginate,
usePost,
useModifyQuery,
usePersist,
useSubscribeQuery,
configure
} from 'react-query-useful-hooks';
Unless provided via the configure
function, react-query-useful-hooks
uses as defaults:
axios
- set axios instance. the default axios
package exportqueryOptions
- set options of useQuery of react-query to set in the options of all queries of useFetch and usePaginatefetchQueryOptions
- set options of useQuery of react-query to set in the options of all queries of useFetchpaginateQueryOptions
- set options of useQuery of react-query to set in the options of all queries of usePaginateinfiniteQueryOptions
- set options of useInfiniteQuery of react-query to set in the options of all queries of useInfinitemutationOptions
- set options of useMutation of react-query to set in the options of all usePostThese defaults may not suit your needs, for example:
In such cases you can use the configure
function to provide your custom implementation of both.
When
configure
is used, it should be invoked once before any usages of hooks
import { configure } from 'react-query-useful-hooks'
import axios from 'axios'
configure({
axios: axios.create({
baseURL: 'https://jsonplaceholder.typicode.com',
timeout: 1000
}),
queryOptions: {
retry: 5,
retryDelay: 100,
retryOnMount: false
}
});
Sina Shah Oveisi @sinashahoveisi
I love programming, and I am interested in popular frameworks or programming languages and I am currently coding with JavaScript and React framework.
FAQs
The best and useful hooks for [react-query]
We found that react-query-useful-hooks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.