Optional
apiA function to get the authorization token for API requests. If not provided, or if the function returns an empty string, no authorization token will be used.
Optional
apiThe function to use for making API requests.
Defaults to fetcher
from react-query-manager
.
Optional
apiIf true
, the returned URL will have a trailing slash.
Optional
apiA function to get the headers for API requests. If not provided, or if the function returns an empty object, no headers will be used.
Optional
apiA callback to run when an API request fails. If not provided, the default behavior will be used.
Optional
apiA callback to run when an API request is successful. If not provided, the default behavior will be used.
The base URL for all API requests.
The children components to render.
Optional
config?: QueryClientConfigThe configuration for the underlying QueryClient instance.
Optional
devOptions to pass to the React Query devtools.
Optional
isWhether to render the React Query devtools.
Defaults to false
.
Optional
toast?: { Options for the
toast
utility from react-hot-toast
.
See the documentation for more details.
The wrapper
property can be used to customize the toast component.
The globalProps
property can be used to customize the default props for the toast component.
The ToastCustomUndoContent
property can be used to customize the content of the toast when the user
clicks the "UNDO" button.
Optional
CustomOptional
CustomOptional
globalimport { RQWrapper, ToastCustomContent, ToastBar } from 'react-query-manager';
const ToastWrapper: ToastCustomContent = (props) => {
return <ToastBar toast={props} position={props.position} />;
};
<RQWrapper
isDevTools
devToolsOptions={{
buttonPosition: 'bottom-left',
}}
apiUrl="https://jsonplaceholder.typicode.com"
apiAuthorization={() => 'Bearer 12345'}
apiOnSuccess={(...args) => {
console.log('apiOnSuccess: ', args);
}}
apiOnError={(...args) => {
console.log('apiOnError: ', args);
}}
toast={{
globalProps: {
position: 'bottom-center',
},
wrapper: ToastWrapper,
}}
>
<List />
</RQWrapper>
This component wraps your application and provides the necessary context for the hooks to work.