eBay / nice-modal-react

A modal state manager for React.
https://ebay.github.io/nice-modal-react
MIT License
1.96k stars 110 forks source link

Add ability to resolve/reject and hide #99

Open adrhumphreys opened 1 year ago

adrhumphreys commented 1 year ago

Hey team,

Loving the library and I found that I often would call resolve and hide or reject and hide, and noticed that there was a similar pattern mentioned in #88

This would mean that users are able to do something like:

const {resolveAndHide} = useModal()

return (
  <Modal onClose={() => resolveAndHide(false)}>
   <p>Content</p>
  </Modal>
)

Happy to update with any feedback

Reason for creating new methods was to keep backwards compatibility

codecov-commenter commented 1 year ago

Codecov Report

Merging #99 (70fa54b) into main (f146959) will decrease coverage by 2.88%. The diff coverage is 25.00%.

@@             Coverage Diff             @@
##              main      #99      +/-   ##
===========================================
- Coverage   100.00%   97.12%   -2.88%     
===========================================
  Files            1        1              
  Lines          201      209       +8     
  Branches        30       30              
===========================================
+ Hits           201      203       +2     
- Misses           0        6       +6     
Impacted Files Coverage Δ
src/index.tsx 97.12% <25.00%> (-2.88%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

supnate commented 1 year ago

Hi @adrhumphreys , thanks for the PR! It looks good to me. Could you please also add unit tests for the new APIs so that it would be merged?

adrhumphreys commented 1 year ago

Hey @supnate sorry for the long delay, just added in some tests now if you want to have a review over them, thanks