Skip to content

Add notifyChange prop to useInputState#418

Merged
severo merged 8 commits intomasterfrom
react-rules
Feb 5, 2026
Merged

Add notifyChange prop to useInputState#418
severo merged 8 commits intomasterfrom
react-rules

Conversation

@severo
Copy link
Copy Markdown
Contributor

@severo severo commented Feb 5, 2026

It will be used later to react to changes in the controlled value.

Also improve docstrings, and rework the useInputState tests.

Copy link
Copy Markdown
Contributor

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 adds a notifyChange callback prop to the useInputState hook, which is called whenever the state value changes, regardless of whether the component is in controlled or uncontrolled mode. This differs from the existing onChange callback, which is only called for user-initiated changes.

Changes:

  • Added notifyChange prop to UseInputStateProps interface with detailed documentation
  • Updated implementation to track controlled value changes and call notifyChange appropriately
  • Improved docstrings for the hook's return type
  • Comprehensive test coverage for the new notifyChange functionality in both controlled and uncontrolled modes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/hooks/useInputState.ts Adds notifyChange prop, updates state management to detect controlled value changes and invoke the callback, improves documentation
test/hooks/useInputState.test.ts Adds comprehensive tests for notifyChange behavior in both controlled and uncontrolled modes, verifies it's not called on init but is called on value changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/hooks/useInputState.test.ts
Comment thread src/hooks/useInputState.ts Outdated
Comment thread test/hooks/useInputState.test.ts Outdated
Comment thread test/hooks/useInputState.test.ts Outdated
Comment thread src/hooks/useInputState.ts Outdated
Comment thread src/hooks/useInputState.ts Outdated
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/hooks/useInputState.ts Outdated
@severo severo merged commit b6a0995 into master Feb 5, 2026
5 checks passed
@severo severo deleted the react-rules branch February 5, 2026 14:07
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