@hyeon/react-use
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -15,3 +15,3 @@ import { pipe } from 'fp-ts/lib/function'; | ||
const transformedKey = transformFn(key); | ||
const transformedValue = typeof value === 'object' ? transformObjectKeys(value, transformFn) : value; | ||
const transformedValue = typeof value === 'object' && value !== null && !Array.isArray(value) ? transformObjectKeys(value, transformFn) : value; | ||
return { | ||
@@ -21,7 +21,6 @@ ...acc, | ||
}; | ||
})); // TODO: 받아온 타입을 그대로 반환하도록 하는 더 좋은 방법 타입을 추론할 수 있도록 | ||
})); | ||
} | ||
const useRemoveSpaceProgramming = initialState => { | ||
const [value, setValue] = useState(transformObjectKeys(initialState)); | ||
const useRemoveSpaceProgramming = (initialState, fn) => { | ||
const [value, setValue] = useState(transformObjectKeys(initialState, fn)); | ||
const setRemoveSpaceProgramming = useCallback(tree => setValue(tree), [setValue]); | ||
@@ -28,0 +27,0 @@ return [value, setRemoveSpaceProgramming]; |
@@ -1,7 +0,7 @@ | ||
type RecordObject = Record<string, unknown>; | ||
type RecordObject = Record<string, any>; | ||
declare function transformObjectKeys<T extends RecordObject>(obj: T, transformFn?: (key?: string) => string): RecordObject; | ||
export declare const useRemoveSpaceProgramming: <T extends RecordObject>(initialState: T) => [T, (v: T) => void]; | ||
export declare const useRSP: <T extends RecordObject>(initialState: T) => [T, (v: T) => void]; | ||
export declare const useRemoveSpaceProgramming: <T extends RecordObject>(initialState: T, fn?: ((key?: string) => string) | undefined) => [T, (v: T) => void]; | ||
export declare const useRSP: <T extends RecordObject>(initialState: T, fn?: ((key?: string) => string) | undefined) => [T, (v: T) => void]; | ||
export default useRemoveSpaceProgramming; | ||
export declare const useObj2KeyMap: <T extends RecordObject>(initialState: T) => [T, (v: T) => void]; | ||
export declare const useObj2KeyMap: <T extends RecordObject>(initialState: T, fn?: ((key?: string) => string) | undefined) => [T, (v: T) => void]; | ||
export declare const obj2keyMap: typeof transformObjectKeys; |
{ | ||
"name": "@hyeon/react-use", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
8529