Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mefengl/query-unnecessary
https://github.com/mefengl/query-unnecessary
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mefengl/query-unnecessary
- Owner: mefengl
- License: mit
- Created: 2023-04-22T17:09:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-22T17:13:47.000Z (over 1 year ago)
- Last Synced: 2024-10-30T10:15:42.327Z (about 2 months ago)
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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',
},
})
}
```