useQuery ​
Hook that defines the logic when query data
typescript
import { useQuery } from '@elysiumorg/solid-use';Usage ​
typescript
const { data, isLoading, isError, isSuccess, error, refetch, isRefetching } = useQuery(() = > fetch('https://example.com/data'));
Demo ​
Api ​
Parameters
| Name | Type | Default | Note | 
|---|---|---|---|
| callback | () => Promise<Data> | - | The callback function to be invoked | 
| options.keys? | DependencyList | - | The dependencies for the hook | 
| options.onSuccess? | (data: Data) => void | - | The callback function to be invoked on success | 
| options.onError? | (error: Error) => void | - | The callback function to be invoked on error | 
| options.select? | UseQueryOptionsSelect<Data> | - | The select function to be invoked | 
| options.initialData? | Data | (() => Data) | - | The initial data for the hook | 
| options.placeholderData? | Data | (() => Data) | - | The placeholder data for the hook | 
| options.refetchInterval? | number | - | The refetch interval | 
| options.retry? | boolean | number | - | The retry count of requests |