Relative Content

Tag Archive for reactjsmaterial-uimedia-queries

useMediaQuery does not work in top level React component but works in child component

When I use useMediaQuery from Material UI in my React app in the top level component (App) of my app, the query doesn’t work (value doesn’t update on window resize) and causes rendering issues (when using Chrome’s dev tools mobile screen emulators). But if I move the query in to a child component (AppContainer), it works. Is it because the containing component needs to have some kind of size attributes?
Here is my top level component with the query: