Skip to content

Conversation

wo-o29
Copy link
Contributor

@wo-o29 wo-o29 commented Sep 13, 2025

Overview

This PR updates both the code and documentation for the usePrevious hook to remove undefined from the compare function's argument types and from the return type.

Since the state parameter passed to the hook is a required value and always provided, and the initial state is stored in prevRef, the prev argument never becomes undefined during the hook's lifecycle. Thus, the hook also never returns undefined.

This update ensures consistency between implementation, type definitions, and documentation, clarifying the intended usage.

Before After
스크린샷 2025-09-13 오후 3 47 08 스크린샷 2025-09-13 오후 3 47 16

Checklist

  • Did you write the test code?
  • Have you run yarn run fix to format and lint the code and docs?
  • Have you run yarn run test:coverage to make sure there is no uncovered line?
  • Did you write the JSDoc?

@Copilot Copilot AI review requested due to automatic review settings September 13, 2025 06:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the usePrevious hook to remove undefined from both the compare function's argument types and the return type, making the type definitions more accurate to reflect the actual behavior where the hook always returns a value of type T.

  • Updated type signatures to remove undefined from compare function parameter and return type
  • Updated documentation in both English and Korean to reflect the corrected types
  • Modified the default comparison function to match the new type signature

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/hooks/usePrevious/usePrevious.ts Updated type signatures and JSDoc comments to remove undefined types
src/hooks/usePrevious/usePrevious.md Updated documentation interface to reflect corrected types
src/hooks/usePrevious/ko/usePrevious.md Updated Korean documentation interface to reflect corrected types

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5bdb4ff) to head (57bbf08).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #272   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           37        37           
  Lines         1093      1093           
  Branches       324       324           
=========================================
  Hits          1093      1093           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants