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

fix: reject non-boolean value as a defaultValue for useBoolean #561

Merged
merged 2 commits into from
Apr 4, 2024

Conversation

luckrnx09
Copy link
Contributor

No description provided.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link

changeset-bot bot commented Mar 27, 2024

🦋 Changeset detected

Latest commit: 365a579

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

* @public
* @see [Documentation](https://usehooks-ts.com/react-hook/use-boolean)
* @example
* ```tsx
* const { value, setTrue, setFalse, toggle } = useBoolean(true);
* ```
*/
export function useBoolean(defaultValue?: boolean): UseBooleanReturn {
const [value, setValue] = useState(!!defaultValue)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Invoid to use !!, It reduces readability.

@luckrnx09 luckrnx09 marked this pull request as ready for review March 27, 2024 14:22
Copy link
Owner

@juliencrn juliencrn left a comment

Choose a reason for hiding this comment

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

Good 👍

@juliencrn juliencrn merged commit 90a33f5 into juliencrn:master Apr 4, 2024
1 of 2 checks passed
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

2 participants