index.js (402B)
1 import { h, Component } from 'preact'; 2 3 export default class UpdateOnResize extends Component { 4 doIt = () => { 5 this.props.action(); 6 } 7 componentDidMount() { 8 window.addEventListener('resize', this.doIt); 9 } 10 componentWillUnmount() { 11 window.removeEventListener('resize', this.DoIt); 12 } 13 render() { 14 return <span>{this.props.children}</span>; 15 } 16 }