OptionalapiA 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.
OptionalapiThe function to use for making API requests.
Defaults to fetcher from react-query-manager.
OptionalapiIf true, the returned URL will have a trailing slash.
OptionalapiA function to get the headers for API requests. If not provided, or if the function returns an empty object, no headers will be used.
OptionalapiA callback to run when an API request fails. If not provided, the default behavior will be used.
OptionalapiA 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.
Optionalconfig?: QueryClientConfigThe configuration for the underlying QueryClient instance.
OptionaldevOptions to pass to the React Query devtools.
OptionalisWhether to render the React Query devtools.
Defaults to false.
Optionaltoast?: { 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.
OptionalCustomOptionalCustomOptionalglobalimport { 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.