Comparing version 3.3.0 to 3.3.8
@@ -33,7 +33,3 @@ var __read = this && this.__read || function (o, n) { | ||
import useUpdateEffect from '../useUpdateEffect'; | ||
function isFunction(obj) { | ||
return typeof obj === 'function'; | ||
} | ||
import { isFunction } from '../utils'; | ||
export function createUseStorageState(getStorage) { | ||
@@ -40,0 +36,0 @@ function useStorageState(key, options) { |
@@ -0,1 +1,2 @@ | ||
import { createUpdateEffect } from './createUpdateEffect'; | ||
import useAntdTable from './useAntdTable'; | ||
@@ -45,3 +46,5 @@ import useAsyncEffect from './useAsyncEffect'; | ||
import usePrevious from './usePrevious'; | ||
import useRafInterval from './useRafInterval'; | ||
import useRafState from './useRafState'; | ||
import useRafTimeout from './useRafTimeout'; | ||
import useReactive from './useReactive'; | ||
@@ -73,5 +76,2 @@ import useRequest, { clearCache } from './useRequest'; | ||
import useWhyDidYouUpdate from './useWhyDidYouUpdate'; | ||
import { createUpdateEffect } from './createUpdateEffect'; | ||
import useRafInterval from './useRafInterval'; | ||
import useRafTimeout from './useRafTimeout'; | ||
export { useRequest, useControllableValue, useDynamicList, useVirtualList, useResponsive, useEventEmitter, useLocalStorageState, useSessionStorageState, useSize, configResponsive, useUpdateEffect, useUpdateLayoutEffect, useBoolean, useToggle, useDocumentVisibility, useSelections, useThrottle, useThrottleFn, useThrottleEffect, useDebounce, useDebounceFn, useDebounceEffect, usePrevious, useMouse, useScroll, useClickAway, useFullscreen, useInViewport, useKeyPress, useEventListener, useHover, useUnmount, useSet, useMemoizedFn, useMap, useCreation, useDrag, useDrop, useMount, useCounter, useUpdate, useTextSelection, useEventTarget, useHistoryTravel, useCookieState, useSetState, useInterval, useWhyDidYouUpdate, useTitle, useNetwork, useTimeout, useReactive, useFavicon, useCountDown, useWebSocket, useLockFn, useUnmountedRef, useExternal, useSafeState, useLatest, useIsomorphicLayoutEffect, useDeepCompareEffect, useAsyncEffect, useLongPress, useRafState, useTrackedEffect, usePagination, useAntdTable, useFusionTable, useInfiniteScroll, useGetState, clearCache, useFocusWithin, createUpdateEffect, useRafInterval, useRafTimeout, }; |
@@ -0,1 +1,2 @@ | ||
import { createUpdateEffect } from './createUpdateEffect'; | ||
import useAntdTable from './useAntdTable'; | ||
@@ -45,3 +46,5 @@ import useAsyncEffect from './useAsyncEffect'; | ||
import usePrevious from './usePrevious'; | ||
import useRafInterval from './useRafInterval'; | ||
import useRafState from './useRafState'; | ||
import useRafTimeout from './useRafTimeout'; | ||
import useReactive from './useReactive'; | ||
@@ -73,5 +76,2 @@ import useRequest, { clearCache } from './useRequest'; | ||
import useWhyDidYouUpdate from './useWhyDidYouUpdate'; | ||
import { createUpdateEffect } from './createUpdateEffect'; | ||
import useRafInterval from './useRafInterval'; | ||
import useRafTimeout from './useRafTimeout'; | ||
export { useRequest, useControllableValue, useDynamicList, useVirtualList, useResponsive, useEventEmitter, useLocalStorageState, useSessionStorageState, useSize, configResponsive, useUpdateEffect, useUpdateLayoutEffect, useBoolean, useToggle, useDocumentVisibility, useSelections, useThrottle, useThrottleFn, useThrottleEffect, useDebounce, useDebounceFn, useDebounceEffect, usePrevious, useMouse, useScroll, useClickAway, useFullscreen, useInViewport, useKeyPress, useEventListener, useHover, useUnmount, useSet, useMemoizedFn, useMap, useCreation, useDrag, useDrop, useMount, useCounter, useUpdate, useTextSelection, useEventTarget, useHistoryTravel, useCookieState, useSetState, useInterval, useWhyDidYouUpdate, useTitle, useNetwork, useTimeout, useReactive, useFavicon, useCountDown, useWebSocket, useLockFn, useUnmountedRef, useExternal, useSafeState, useLatest, useIsomorphicLayoutEffect, useDeepCompareEffect, useAsyncEffect, useLongPress, useRafState, useTrackedEffect, usePagination, useAntdTable, useFusionTable, useInfiniteScroll, useGetState, clearCache, useFocusWithin, createUpdateEffect, useRafInterval, useRafTimeout }; |
@@ -0,1 +1,2 @@ | ||
import type { SetStateAction } from 'react'; | ||
export interface Options<T> { | ||
@@ -13,4 +14,4 @@ defaultValue?: T; | ||
} | ||
declare function useControllableValue<T = any>(props: StandardProps<T>): [T, (val: T) => void]; | ||
declare function useControllableValue<T = any>(props?: Props, options?: Options<T>): [T, (v: T, ...args: any[]) => void]; | ||
declare function useControllableValue<T = any>(props: StandardProps<T>): [T, (v: SetStateAction<T>) => void]; | ||
declare function useControllableValue<T = any>(props?: Props, options?: Options<T>): [T, (v: SetStateAction<T>, ...args: any[]) => void]; | ||
export default useControllableValue; |
@@ -37,2 +37,3 @@ var __read = this && this.__read || function (o, n) { | ||
import { useMemo, useRef } from 'react'; | ||
import { isFunction } from '../utils'; | ||
import useMemoizedFn from '../useMemoizedFn'; | ||
@@ -78,3 +79,3 @@ import useUpdate from '../useUpdate'; | ||
var setState = function setState(v) { | ||
function setState(v) { | ||
var args = []; | ||
@@ -86,4 +87,6 @@ | ||
var r = isFunction(v) ? v(stateRef.current) : v; | ||
if (!isControlled) { | ||
stateRef.current = v; | ||
stateRef.current = r; | ||
update(); | ||
@@ -93,5 +96,5 @@ } | ||
if (props[trigger]) { | ||
props[trigger].apply(props, __spread([v], args)); | ||
props[trigger].apply(props, __spread([r], args)); | ||
} | ||
}; | ||
} | ||
@@ -98,0 +101,0 @@ return [stateRef.current, useMemoizedFn(setState)]; |
@@ -48,5 +48,3 @@ "use strict"; | ||
function isFunction(obj) { | ||
return typeof obj === 'function'; | ||
} | ||
var utils_1 = require("../utils"); | ||
@@ -90,3 +88,3 @@ function createUseStorageState(getStorage) { | ||
if (isFunction(options === null || options === void 0 ? void 0 : options.defaultValue)) { | ||
if (utils_1.isFunction(options === null || options === void 0 ? void 0 : options.defaultValue)) { | ||
return options === null || options === void 0 ? void 0 : options.defaultValue(); | ||
@@ -112,3 +110,3 @@ } | ||
storage === null || storage === void 0 ? void 0 : storage.removeItem(key); | ||
} else if (isFunction(value)) { | ||
} else if (utils_1.isFunction(value)) { | ||
var currentState = value(state); | ||
@@ -115,0 +113,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { createUpdateEffect } from './createUpdateEffect'; | ||
import useAntdTable from './useAntdTable'; | ||
@@ -45,3 +46,5 @@ import useAsyncEffect from './useAsyncEffect'; | ||
import usePrevious from './usePrevious'; | ||
import useRafInterval from './useRafInterval'; | ||
import useRafState from './useRafState'; | ||
import useRafTimeout from './useRafTimeout'; | ||
import useReactive from './useReactive'; | ||
@@ -73,5 +76,2 @@ import useRequest, { clearCache } from './useRequest'; | ||
import useWhyDidYouUpdate from './useWhyDidYouUpdate'; | ||
import { createUpdateEffect } from './createUpdateEffect'; | ||
import useRafInterval from './useRafInterval'; | ||
import useRafTimeout from './useRafTimeout'; | ||
export { useRequest, useControllableValue, useDynamicList, useVirtualList, useResponsive, useEventEmitter, useLocalStorageState, useSessionStorageState, useSize, configResponsive, useUpdateEffect, useUpdateLayoutEffect, useBoolean, useToggle, useDocumentVisibility, useSelections, useThrottle, useThrottleFn, useThrottleEffect, useDebounce, useDebounceFn, useDebounceEffect, usePrevious, useMouse, useScroll, useClickAway, useFullscreen, useInViewport, useKeyPress, useEventListener, useHover, useUnmount, useSet, useMemoizedFn, useMap, useCreation, useDrag, useDrop, useMount, useCounter, useUpdate, useTextSelection, useEventTarget, useHistoryTravel, useCookieState, useSetState, useInterval, useWhyDidYouUpdate, useTitle, useNetwork, useTimeout, useReactive, useFavicon, useCountDown, useWebSocket, useLockFn, useUnmountedRef, useExternal, useSafeState, useLatest, useIsomorphicLayoutEffect, useDeepCompareEffect, useAsyncEffect, useLongPress, useRafState, useTrackedEffect, usePagination, useAntdTable, useFusionTable, useInfiniteScroll, useGetState, clearCache, useFocusWithin, createUpdateEffect, useRafInterval, useRafTimeout, }; |
@@ -48,2 +48,11 @@ "use strict"; | ||
var createUpdateEffect_1 = require("./createUpdateEffect"); | ||
Object.defineProperty(exports, "createUpdateEffect", { | ||
enumerable: true, | ||
get: function get() { | ||
return createUpdateEffect_1.createUpdateEffect; | ||
} | ||
}); | ||
var useAntdTable_1 = __importDefault(require("./useAntdTable")); | ||
@@ -225,2 +234,6 @@ | ||
var useRafInterval_1 = __importDefault(require("./useRafInterval")); | ||
exports.useRafInterval = useRafInterval_1["default"]; | ||
var useRafState_1 = __importDefault(require("./useRafState")); | ||
@@ -230,2 +243,6 @@ | ||
var useRafTimeout_1 = __importDefault(require("./useRafTimeout")); | ||
exports.useRafTimeout = useRafTimeout_1["default"]; | ||
var useReactive_1 = __importDefault(require("./useReactive")); | ||
@@ -350,19 +367,2 @@ | ||
exports.useWhyDidYouUpdate = useWhyDidYouUpdate_1["default"]; | ||
var createUpdateEffect_1 = require("./createUpdateEffect"); | ||
Object.defineProperty(exports, "createUpdateEffect", { | ||
enumerable: true, | ||
get: function get() { | ||
return createUpdateEffect_1.createUpdateEffect; | ||
} | ||
}); | ||
var useRafInterval_1 = __importDefault(require("./useRafInterval")); | ||
exports.useRafInterval = useRafInterval_1["default"]; | ||
var useRafTimeout_1 = __importDefault(require("./useRafTimeout")); | ||
exports.useRafTimeout = useRafTimeout_1["default"]; | ||
exports.useWhyDidYouUpdate = useWhyDidYouUpdate_1["default"]; |
@@ -0,1 +1,2 @@ | ||
import type { SetStateAction } from 'react'; | ||
export interface Options<T> { | ||
@@ -13,4 +14,4 @@ defaultValue?: T; | ||
} | ||
declare function useControllableValue<T = any>(props: StandardProps<T>): [T, (val: T) => void]; | ||
declare function useControllableValue<T = any>(props?: Props, options?: Options<T>): [T, (v: T, ...args: any[]) => void]; | ||
declare function useControllableValue<T = any>(props: StandardProps<T>): [T, (v: SetStateAction<T>) => void]; | ||
declare function useControllableValue<T = any>(props?: Props, options?: Options<T>): [T, (v: SetStateAction<T>, ...args: any[]) => void]; | ||
export default useControllableValue; |
@@ -50,2 +50,4 @@ "use strict"; | ||
var utils_1 = require("../utils"); | ||
var useMemoizedFn_1 = __importDefault(require("../useMemoizedFn")); | ||
@@ -92,3 +94,3 @@ | ||
var setState = function setState(v) { | ||
function setState(v) { | ||
var args = []; | ||
@@ -100,4 +102,6 @@ | ||
var r = utils_1.isFunction(v) ? v(stateRef.current) : v; | ||
if (!isControlled) { | ||
stateRef.current = v; | ||
stateRef.current = r; | ||
update(); | ||
@@ -107,5 +111,5 @@ } | ||
if (props[trigger]) { | ||
props[trigger].apply(props, __spread([v], args)); | ||
props[trigger].apply(props, __spread([r], args)); | ||
} | ||
}; | ||
} | ||
@@ -112,0 +116,0 @@ return [stateRef.current, useMemoizedFn_1["default"](setState)]; |
{ | ||
"name": "ahooks", | ||
"version": "3.3.0", | ||
"version": "3.3.8", | ||
"description": "react hooks library", | ||
@@ -31,2 +31,3 @@ "keywords": [ | ||
"es", | ||
"metadata.json", | ||
"package.json", | ||
@@ -63,3 +64,3 @@ "README.md" | ||
"license": "MIT", | ||
"gitHead": "098a914a1eada8c72ac7381dcd915f0b52f6c807" | ||
"gitHead": "2d1cc85e6ef0ae4a32f2115035a87a1bb643a17f" | ||
} |
@@ -73,4 +73,5 @@ <p align="center"> | ||
<img src="https://user-images.githubusercontent.com/12526493/141303172-68f25577-c7b7-4ff7-bdff-25fd0f4d5214.JPG" width="300" /> | ||
<img src="https://user-images.githubusercontent.com/12526493/163084546-ed7a18a8-f05b-484e-a32c-049a05c350fd.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/12526493/163084577-bab53c55-610e-4efe-96c7-eb0dd076c100.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/12526493/163084584-bfb789fe-b5f4-4cd6-b4a5-2444bd67c1a5.JPG" width="200" style='display:inline'/> | ||
[1]: https://www.npmjs.com/package/ahooks | ||
@@ -77,0 +78,0 @@ [2]: https://npmjs.org/package/ahooks |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
658320
16396
80