react-use icon indicating copy to clipboard operation
react-use copied to clipboard

feat: adding restoreOriginalOnUnmount to useTitle

Open gavinbm opened this issue 1 year ago • 1 comments

Description

New option added to the UseTitleOptions interface that will restore the first title passed into useTitle, as requested in issue #2561. I used useMemo to memoize it, I also added one test case to make sure it would pass. One issue that I need help with is determining what to do if both restoreOnUnmount and restoreOriginalOnUnmount are both true at the same time. I'm not sure how that should be handled.

Type of change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as before)

Checklist

  • [x] Read the Contributing Guide
  • [x] Perform a code self-review
  • [x] Comment the code, particularly in hard-to-understand areas
  • [ ] Add documentation
  • [ ] Add hook's story at Storybook
  • [x] Cover changes with tests
  • [x] Ensure the test suite passes (yarn test)
  • [ ] Provide 100% tests coverage
  • [x] Make sure code lints (yarn lint). Fix it with yarn lint:fix in case of failure.
  • [x] Make sure types are fine (yarn lint:types).

gavinbm avatar Jun 15 '24 03:06 gavinbm

Hi @gavinbm,

I agree having both options makes little sense. You either want to restore to the previous, the default or not at all. What about an enum instead of a boolean?

restore: 'previous' | 'default' | 'off' (or null/undefined)

StructuralRealist avatar Aug 12 '24 09:08 StructuralRealist