Skip to content

Commit

Permalink
feat: used @pansy/shared isFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxingkang committed Aug 29, 2022
1 parent e395c0a commit d3f1cb1
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 20 deletions.
1 change: 1 addition & 0 deletions hooks/useControllableValue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"dependencies": {
"@pansy/shared": "^1.2.0",
"@pansy/use-memoized-fn": "0.2.5",
"@pansy/use-update": "0.2.4"
},
Expand Down
2 changes: 1 addition & 1 deletion hooks/useControllableValue/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemo, useRef } from 'react';
import { isFunction } from '@pansy/hook-utils';
import { isFunction } from '@pansy/shared';
import { useMemoizedFn } from '@pansy/use-memoized-fn';
import { useUpdate } from '@pansy/use-update';

Expand Down
1 change: 1 addition & 0 deletions hooks/useCookieState/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"dependencies": {
"@pansy/shared": "^1.2.0",
"@pansy/use-memoized-fn": "0.2.5",
"@types/js-cookie": "^2.x.x",
"js-cookie": "^2.x.x"
Expand Down
5 changes: 1 addition & 4 deletions hooks/useCookieState/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Cookies from 'js-cookie';
import { isFunction } from '@pansy/shared';
import { useState } from 'react';
import { useMemoizedFn } from '@pansy/use-memoized-fn';

Expand All @@ -8,10 +9,6 @@ export interface Options extends Cookies.CookieAttributes {
defaultValue?: State | (() => State);
}

export function isFunction(obj: any): obj is Function {
return typeof obj === 'function';
}

export function useCookieState(cookieKey: string, options: Options = {}) {
const [state, setState] = useState<State>(() => {
const cookieValue = Cookies.get(cookieKey);
Expand Down
1 change: 0 additions & 1 deletion hooks/useMemoizedFn/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMemo, useRef } from 'react';
import { isFunction } from '@pansy/hook-utils';

type noop = (...args: any[]) => any;

Expand Down
1 change: 1 addition & 0 deletions hooks/useRequest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"dependencies": {
"@pansy/shared": "^1.2.0",
"@pansy/hook-utils": "0.3.0",
"@pansy/use-creation": "0.1.4",
"@pansy/use-latest": "0.2.4",
Expand Down
2 changes: 1 addition & 1 deletion hooks/useRequest/src/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isFunction } from '@pansy/hook-utils';
import { isFunction } from '@pansy/shared';

import type { MutableRefObject } from 'react';
import type { FetchState, Options, PluginReturn, Service, Subscribe } from './types';
Expand Down
1 change: 0 additions & 1 deletion hooks/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export {
export { canUseDom } from './utils/canUseDom';
export { useIsomorphicLayoutEffectWithTarget } from './utils/useIsomorphicLayoutEffectWithTarget';
export { useDeepCompareEffectWithTarget } from './utils/useDeepCompareWithTarget';
export { isFunction } from './utils/isFunction';

export { createDeepCompareEffect } from './createDeepCompareEffect';

Expand Down
5 changes: 1 addition & 4 deletions hooks/utils/src/utils/createUseStorageState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from 'react';
import { isFunction } from '@pansy/shared';
import { useMemoizedFn } from '@pansy/use-memoized-fn';
import { useUpdateEffect } from '@pansy/use-update-effect';

Expand All @@ -16,10 +17,6 @@ export type FuncUpdater<T> = (previousState?: T) => T;
export type StorageStateResult<T> = [T | undefined, (value?: T | FuncUpdater<T>) => void];
export type StorageStateResultHasDefaultValue<T> = [T, (value?: T | FuncUpdater<T>) => void];

function isFunction<T>(obj: any): obj is T {
return typeof obj === 'function';
}

export function createUseStorageState(getStorage: () => Storage | undefined) {
function useStorageState<T = any>(key: string, options?: Options<T>): StorageStateResult<T>;

Expand Down
8 changes: 0 additions & 8 deletions hooks/utils/src/utils/isFunction.ts

This file was deleted.

0 comments on commit d3f1cb1

Please sign in to comment.