Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mefengl/query-unnecessary


https://github.com/mefengl/query-unnecessary

Last synced: 11 days ago
JSON representation

Awesome Lists containing this project

README

        

# query-unnecessary

```js
// https://tkdodo.eu/blog/breaking-react-querys-api-on-purpose#defining-on-demand-messages
const queryClient = new QueryClient({
queryCache: new QueryCache({
onError: (error, query) => {
if (query.meta.errorMessage) {
toast.error(query.meta.errorMessage)
}
},
}),
})

export function useTodos() {
return useQuery({
queryKey: ['todos', 'list'],
queryFn: fetchTodos,
meta: {
errorMessage: 'Failed to fetch todos',
},
})
}
```