Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/hooks/usePrevious/ko/usePrevious.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
```ts
function usePrevious<T>(
state: T,
compare: (prev: T | undefined, next: T) => boolean
): T | undefined;
compare: (prev: T, next: T) => boolean
): T;
```

### 파라미터
Expand All @@ -22,15 +22,15 @@ function usePrevious<T>(

<Interface
name="compare"
type="(prev: T | undefined, next: T) => boolean"
type="(prev: T, next: T) => boolean"
description="상태가 변경되었는지를 판단하기 위한 선택적 비교 함수예요."
/>

### 반환 값

<Interface
name=""
type="T | undefined"
type="T"
description="상태의 이전 값이에요."
/>

Expand Down
8 changes: 4 additions & 4 deletions src/hooks/usePrevious/usePrevious.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
```ts
function usePrevious<T>(
state: T,
compare: (prev: T | undefined, next: T) => boolean
): T | undefined;
compare: (prev: T, next: T) => boolean
): T;
```

### Parameters
Expand All @@ -22,15 +22,15 @@ function usePrevious<T>(

<Interface
name="compare"
type="(prev: T | undefined, next: T) => boolean"
type="(prev: T, next: T) => boolean"
description="An optional comparison function to determine if the state has changed."
/>

### Return Value

<Interface
name=""
type="T | undefined"
type="T"
description="previous value of the state."
/>

Expand Down
6 changes: 3 additions & 3 deletions src/hooks/usePrevious/usePrevious.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRef } from 'react';

const strictEquals = <T>(prev: T | undefined, next: T) => prev === next;
const strictEquals = <T>(prev: T, next: T) => prev === next;

/**
* @description
Expand All @@ -11,9 +11,9 @@ const strictEquals = <T>(prev: T | undefined, next: T) => prev === next;
*
* @template T - The type of the state.
* @param {T} state - The state whose previous value is to be tracked.
* @param {(prev: T | undefined, next: T) => boolean} [compare] - An optional comparison function to determine if the state has changed.
* @param {(prev: T, next: T) => boolean} [compare] - An optional comparison function to determine if the state has changed.
*
* @returns {T | undefined} The previous value of the state.
* @returns {T} The previous value of the state.
*
* @example
* const [count, setCount] = useState(0);
Expand Down
Loading