onChange is not fired
tambaqui opened this issue ยท 3 comments
tambaqui commented
onChange event is not fired. Tested with react 17.0.1
yocontra commented
Can you give more specifics - code sample, what browser you're testing in, etc.
tambaqui commented
Tested with a small component similar to the one in the doc:
import { useMediaQuery } from 'react-responsive'
const Sample = () => {
const handleMediaQueryChange = (matches) => {
console.log('matches', matches)
}
const isWide = useMediaQuery(
{ minDeviceWidth: 1280 }, undefined, handleMediaQueryChange
);
return (
<div>
Screen is wide: {isWide ? '๐' : '๐ข'}
</div>
)
}
export default Sample
I'm seeing that not only the onChange fails. IsWide detection also fails, which always returns ๐
Tested in Windows 10, with react 17.0.1, react-scripts 4.0.0, react-responsive 8.1.0
Browsers: Chrome 86.0.4240.183, Firefox 82.0.2. Same results in both.
tambaqui commented
I have found the problem. Sorry, my mistake, I was using minDeviceWidth in testing with desktop browsers, when I should be using minWidth.