Skip to content

Commit

Permalink
refactor(ui/hooks): useControllableState의 setValue 내부 setter type 명시 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sukvvon authored Aug 13, 2024
1 parent 26c663f commit 69a298d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions packages/ui/src/hooks/use-controllable-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ type UseControllableStateProps<T> = {
shouldUpdate?: (prev: T, next: T) => boolean;
};

type SetStateFn<T> = (prevState?: T) => T;

export function useControllableState<T>(props: UseControllableStateProps<T>) {
const {
value: valueProp,
Expand All @@ -32,7 +30,7 @@ export function useControllableState<T>(props: UseControllableStateProps<T>) {

const setValue: Dispatch<SetStateAction<T>> = useCallback(
(next) => {
const setter = next as SetStateFn<T>;
const setter = next as (prevState?: T) => T;
const nextValue = typeof next === 'function' ? setter(value) : next;

if (!shouldUpdateProp(value, nextValue)) {
Expand Down

0 comments on commit 69a298d

Please sign in to comment.