Move main files into client/main

This commit is contained in:
Michael Jackson
2018-07-18 00:29:49 -07:00
parent f8eea6ac2b
commit a254a7a2f2
15 changed files with 100 additions and 10 deletions

35
client/main/WindowSize.js Normal file
View File

@ -0,0 +1,35 @@
import React from "react";
import PropTypes from "prop-types";
import addEvent from "../utils/addEvent";
import removeEvent from "../utils/removeEvent";
const resizeEvent = "resize";
class WindowSize extends React.Component {
static propTypes = {
onChange: PropTypes.func
};
handleWindowResize = () => {
if (this.props.onChange)
this.props.onChange({
width: window.innerWidth,
height: window.innerHeight
});
};
componentDidMount() {
addEvent(window, resizeEvent, this.handleWindowResize);
}
componentWillUnmount() {
removeEvent(window, resizeEvent, this.handleWindowResize);
}
render() {
return null;
}
}
export default WindowSize;