Skip to main content

LoadConfig

Config component for useLoad, useReload and useSubmit.

API

import React from "react";
import { LoadConfig } from "@lilib/hooks";
import App from "./App";

function Root() {
return (
<LoadConfig {...}>
<App />
</LoadConfig>
);
}

Props

PropertyTypeDescriptionDefault
globalbooleanUse global instancefalse
inheritbooleanInherit parent configfalse
cacheTimenumberCache time300000
staleTimenumberStale time0
retrybooleanEnable retryfalse
retryLimitnumberCallback retry limit3
retryIntervalnumber | (count: number) => numberCallback retry interval0
fallbackRetrybooleanEnable retry fallbackfalse
fallbackRetryLimitnumberFallback retry limit3
fallbackRetryIntervalnumber | (count: number) => numberFallback retry interval0
pollingbooleanEnable polling when page visiblefalse
pollingIntervalnumberPolling internal when page visible30000
pollingInPageHidingbooleanEnable polling when page hiddenfalse
pollingIntervalInPageHidingnumberPolling internal when page hidden60000
autoReloadWaitTimenumberThrottle wait time on auto reload10000
autoReloadOnPageShowbooleanEnable auto reload on page showfalse
autoReloadOnWindowFocusbooleanEnable auto reload on window focusfalse
autoReloadOnNetworkReconnectbooleanEnable auto reload on network reconnectfalse
onSuccess(data: any, key?: {}) => voidDefault success event-
onFailure(error: any, key?: {}) => voidDefault failure event-
onFinally(key?: {}) => voidDefault finally event-
handleSuccess(data: any, key?: {}) => voidHandle success event-
handleFailure(error: any, key?: {}) => voidHandle failure event-
handleFinally(key?: {}) => voidHandle finally event-

LoadConfig.Context

A React context object that can be used in class component.

LoadConfig.useConfig

A hook returns a config object.

import React from "react";
import { LoadConfig } from "@lilib/hooks";

function Example() {
const config = LoadConfig.useConfig();
...
}