ReactTraining / react-media

CSS media queries for React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onChange callback is not triggered

timkraut opened this issue · comments

Hi,

I've been struggling with the onChange callback. The break point detection works fine but the function I pass to onChange is never called.

I use the following code:

function logOnChange() {
  console.log("changed");
}

function App() {
  return (
    <Media query={{ maxWidth: 500 }} onChange={logOnChange}>
      {matches => (matches ? <p>Small</p> : <p>Large</p>)}
    </Media>
  );
}

I've created a Codesandbox to illustrate the issue:
https://codesandbox.io/s/5v82oypykl

Am I doing something wrong or is this broken?

Thanks in advance!

Hey, the current changes in master haven't been deployed to npm yet. Please follow #98 for progress updates.

I am facing the same issue