DEV Community

Discussion on: React: Custom hook for media queries 📱💻

Collapse
 
httpjunkie profile image
Eric Bishard

I like the tutorial, I'm already using the react-media-hook and it's useMediaPredicate() hook. Have you used that one?

Collapse
 
link2twenty profile image
Andrew Bone

I've not used it but I've just had a look at the code. useMediaPredicate() doesn't update itself, which maybe you would want but it's not something I've added to this one too. useMedia() does the same as this one, without an option to change the query, but uses react useCallback so will use a tiny bit more memory but that's alright.

There's nothing wrong with using something someone else has written but it's good to understand how things work because one day they'll be a hook you need that no-one has made yet. 😅