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

docs(useDefault): Suggest useMediatedState instead #562

Merged
merged 1 commit into from
Apr 25, 2022

Conversation

AndreasNel
Copy link
Contributor

What new hook does?

It works like useSafeState, except it will return the provided default value when the state is set to undefined or null.

Checklist

  • Have you read contribution guideline?
  • Does the code have comments in hard-to-understand areas?
  • Is there an existing issue for this PR?
  • Have the files been linted and formatted?
  • Have the docs been updated?
  • Have the tests been added to cover new hook?
  • Have you run the tests locally to confirm they pass?

@xobotyi
Copy link
Contributor

xobotyi commented Jan 16, 2022

TBH i dont think we need that hook since it is easily (and versatile) achievable via useMediatedState hook.

@JoeDuncko WDYT?

@JoeDuncko
Copy link
Contributor

I wonder if we should have a cookbook of common hooks that can be easily derived from our hooks, or something like that.

Maybe as examples in Storybook?

I know that doesn't exactly answer the question though.

@xobotyi
Copy link
Contributor

xobotyi commented Jan 17, 2022

I've been thinking about that too (cookbook). Maybe separte page near migration and reference in mugration like we dont have this hook implemented directly as it can be easily achieved via other hook, and here is example link.

@AndreasNel
Copy link
Contributor Author

Yeah a cookbook sounds good, do you want me to create such a page? Or would you prefer doing it?

@JoeDuncko
Copy link
Contributor

Yeah a cookbook sounds good, do you want me to create such a page? Or would you prefer doing it?

Sorry for the slow reply. If you know your way around Storybook, go for it! I'm still new to Storybook, so I'd have to figure out the best way to present alternative examples. Ideas welcome.

@xobotyi xobotyi added wontfix This will not be worked on 👎 invalid This doesn't seem right labels Mar 8, 2022
@AndreasNel
Copy link
Contributor Author

Apologies for leaving this for so long, life kind of got in the way and this got away from me. Please check if the documentation suggestion is correct.

@xobotyi xobotyi changed the title feat(useDefault): port useDefault from react-use docs(useDefault): Suggest useMediatedState instead Apr 25, 2022
@xobotyi
Copy link
Contributor

xobotyi commented Apr 25, 2022

LGTM, merging after all check passed.

@codecov
Copy link

codecov bot commented Apr 25, 2022

Codecov Report

Merging #562 (9311a17) into master (409a21f) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master      #562   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           50        50           
  Lines          865       865           
  Branches       162       162           
=========================================
  Hits           865       865           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f8c615...9311a17. Read the comment docs.

@xobotyi xobotyi merged commit af5de33 into react-hookz:master Apr 25, 2022
@xobotyi
Copy link
Contributor

xobotyi commented Apr 25, 2022

🎉 This PR is included in version 13.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👎 invalid This doesn't seem right released wontfix This will not be worked on
Development

Successfully merging this pull request may close these issues.

3 participants