Security News
Supply Chain Attack Detected in @solana/web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
react-query
Advanced tools
Hooks for managing, caching and syncing asynchronous and remote data in React
The react-query npm package is a powerful tool for fetching, caching, and updating asynchronous data in React applications. It provides hooks that enable efficient data synchronization with your server's state without the need to manage complex state logic within your components.
Data Fetching
Use the useQuery hook to fetch data from an API and provide the status of the request. It automatically caches the data and provides a re-fetch mechanism.
const { data, error, isLoading } = useQuery('todos', fetchTodos)
Data Mutation
Use the useMutation hook to create or update data. It integrates with the query cache to automatically update related queries on success.
const mutation = useMutation(newTodo => axios.post('/todos', newTodo), { onSuccess: () => queryClient.invalidateQueries('todos') })
Automatic Refetching
Configure queries to refetch automatically under certain conditions, such as when the window regains focus, to keep data fresh.
const { data } = useQuery('todos', fetchTodos, { refetchOnWindowFocus: true })
Pagination and Infinite Queries
Handle paginated or infinite data sets with useInfiniteQuery, which provides functions to fetch additional pages of data.
const { data, fetchNextPage } = useInfiniteQuery('projects', fetchProjects, { getNextPageParam: lastPage => lastPage.nextCursor })
Query Caching and Sharing
Cache query results to optimize performance and reduce the number of requests. Shared queries with the same key will use cached data when possible.
const { data } = useQuery('todos', fetchTodos, { cacheTime: 1000 * 60 * 60 })
SWR is a React hooks library for data fetching, similar to react-query. It also provides features like caching, revalidation on focus, and pagination. SWR focuses on simplicity and has a smaller API surface compared to react-query.
Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL. It is more tightly coupled with GraphQL than react-query and offers features like caching, optimistic UI updates, and subscription support.
redux-query is a library for querying and managing network state in Redux applications. It integrates with Redux and provides a way to co-locate queries with reducers. It is more Redux-centric compared to react-query and requires more boilerplate.
Hooks for fetching, caching and updating asynchronous data in React
Enjoy this library? Try the entire TanStack! React Table, React Form, React Charts
Thanks goes to these wonderful people (emoji key):
Tanner Linsley 💻 🤔 💡 🚧 👀 | Andrew Cherniavskii 💻 🐛 | Thibaut Tiberghien 📖 | Rohit Garg 🔧 | Avinash 💻 🐛 | Jason O'Neill 🚧 ⚠️ | Jack Zhao 💻 🐛 |
dpyzo0o 💻 | Jelte Liekens 💻 | Jen Gettings 💻 | Justin 💻 | Marcelo Alves 💻 | Zorza 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Hooks for managing, caching and syncing asynchronous and remote data in React
The npm package react-query receives a total of 1,025,559 weekly downloads. As such, react-query popularity was classified as popular.
We found that react-query demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.