Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Update useBoolean hook to accept a function as defaultValue #528

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

talhaibnmahmud
Copy link

This pull request significantly improves the useBoolean hook, enhancing its flexibility without introducing any breaking changes. By extending support for function-based initial states while maintaining consistency with existing usage patterns, this enhancement ensures a seamless transition for users while offering new possibilities for dynamic state initialization.

  • Function-Based Initial State Support: The useBoolean hook now gracefully handles function-based initial states alongside boolean values. This enhancement empowers users to dynamically compute the initial state, enabling more advanced use cases where the initial state depends on asynchronous or complex computations.
  • Preserving Code Clarity: The updated hook maintains code clarity and readability despite the added flexibility. Developers can continue to use familiar methods like setTrue, setFalse, and toggle, ensuring a consistent and intuitive interface for managing the boolean state.
  • Non-Breaking Changes: Importantly, these enhancements are introduced without breaking changes. Existing implementations of the useBoolean hook remain fully compatible, ensuring a smooth transition for users and minimizing potential disruptions to ongoing development efforts.

Copy link

changeset-bot bot commented Mar 6, 2024

🦋 Changeset detected

Latest commit: f788541

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
usehooks-ts Patch
www Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@talhaibnmahmud talhaibnmahmud changed the title Update useBoolean hook to accept a function as defaultValue improvement: Update useBoolean hook to accept a function as defaultValue Mar 6, 2024
@talhaibnmahmud talhaibnmahmud changed the title improvement: Update useBoolean hook to accept a function as defaultValue Improvement: Update useBoolean hook to accept a function as defaultValue Mar 6, 2024
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.

None yet

1 participant