react-use
react-use copied to clipboard
fix(useMeasure): allow null element
Description
With strictNullChecks enabled in typescript UseMeasureRef complains
that it's being passed something that may be null.
It's already checking for nulls with if (!element) return;, so it
should be no problem changing the type to allow it.
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] 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
- [ ] Comment the code, particularly in hard-to-understand areas
- [ ] Add documentation
- [ ] Add hook's story at Storybook
- [ ] 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 withyarn lint:fixin case of failure. - [x] Make sure types are fine (
yarn lint:types).
@streamich This has been open for a while now... Are there any blockers or could it get merged soon?
I'd give up on this one if I were you :cry: https://github.com/streamich/react-use/issues/1974

I've been using https://react-hookz.github.io/web/?path=/docs/sensor-usemeasure--example for a while now, and it works like a charm :wink:
Yeah, I just got caught up on the discussion about forking/starting over with react-hookz/web and I see that this project is a dead end. I'll see if I can find some time to migrate then...