@mystify/mediaquerylist
v1.0.13
Published
A simple class for media query lists that allows me to get around the addListener not supported on some browsers.
Downloads
1
Readme
usage:
import MediaQueryList from "@mystify/mediaQueryList";
componentDidMount() {
this.mql = new MediaQueryList('(max-width: 960px)');
this.mql.addListener(this.mediaQueryChanged);
}
mediaQueryChanged = e => {
if (this.mql.matches) {
// do something here
}
else {
// do something else here
}
};
componentWillUnmount() {
if (this.mql) this.mql.removeListener(this.mediaQueryChanged);
}