I find myself constantly switching between useMediaQuery hook (on pages) and largerThan or smallerThan in components.
The issue that I'm facing, is that - if I get it right - these two don't mean exactly the same thing. There's what I'm trying to say
Assuming xl size is defined at 1440 pixels.
[theme.fn.largerThan("xl")]: {
paddingLeft: 100,
paddingRight: 100
}
^ this means that a padding applies to sizes 1441+ (Basically, it takes the XL size and adds 1). But not on exactly 1440
That's all cool, but then on the page I might have something like
const largeScreen = useMediaQuery(`(min-width: ${theme.breakpoints.xl}px)`);
<Text
px={largeScreen ? 100 : 0}>
Lorem Ipsum
</Text>
If this second case, I will get a padding left/right of 100px also on 1440 width size.
This make the two approaches not bahaving the same way. Is this normal? What's the best way to do this?
I've currently settled for adding a +1 to useMediaQuery. But this feels like a "hack" that another person working with me on the project won't understand.
useMediaQuery(`(min-width: ${theme.breakpoints.xl + 1}px)`)