Closed Merri closed 4 years ago
Yeah when I switched to returning an object instead of an array I didn't consider this possibility, but I think you're right. 🤔
You can do it with arrays, too!
const [ref, width = 100, height = 50] = useOlderResizeObserver()
Ah, good to know!
Released. Demo got updates as well here: https://codesandbox.io/s/use-resize-observer-ssr-default-values-hrvt2
I'm wondering about the defaults, because they seem to provide nothing of value that can't be done with just JavaScript:
This gives 100 x 50 until client side code kicks in.
It would make sense to encourage people to use JS features and keep hook's feature set and size as small as possible. (Unless I'm wrong here and I'm simply used to some extra feature not commonly available in most codebases.)