Advanced usage
The main goal of this SDK is to provide simple, zero-config hooks API to make interaction with spinamp database quick and easy. However, there are several possibilities to take more control and configure it with the same freedom, as by using react-query directly.
Every
use[Whatever]Queryhook exposed from this library takes react-queryUseQueryOptions / UseInfiniteQueryOptionsobject as the last argument. It also returns all properties returned from react-query extended with some directly accessible entities liketracks,artist, etc (https://tanstack.com/query/v4/docs/reference/useQuery).There is
setSpinampClientOptionsfunction exposed, which allows to set some defaults onQueryClientinstance (https://tanstack.com/query/v4/docs/reference/QueryClient#queryclientsetdefaultoptions).If it's not enough, you can import
spinampQueryClientdirectly and do whatever is possible with react-query API. For example, you can make your cache persistent by usingspinampQueryClientwithpersistQueryClientfunction (https://tanstack.com/query/v4/docs/plugins/persistQueryClient).If you are using react-query in your app already, and you would like to keep
spinamp-hooksdata under the sameQueryClientas the rest of the app, there is an option to do that in three steps:Remove
SpinampProvidercomponent wrapper, so there is only oneQueryClientProvider.Set
contextSharingprop on yourQueryClientProvidertotrue.Call
enableCustomSpinampProvider()fromspinamp-hooksat the root of your app. It's needed to disable using internal context inspinamp-hooksand switch it to the default one.
Last updated