0.2.0 • Published 8 years ago

react-window-state v0.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

react-window-state

NPM version Build Status Test coverage Dependency Status

Pass updated window width and height as props on resize. Highly inspired by react-window-mixin.

Install

$ npm install react-window-state

Usage

import { withWindowState } from 'react-window-state';

const WrappedComponent = withWindowState(BaseComponent);

class App extends Component {
  render() {
    return <WrappedComponent />;
  }
}

class BaseComponent extends Component {
  render() {
    // retrieve updated window, document state from props
    const { win, doc } = this.props;
    return (
      <div>
        <p>window - width: {win.width}, height: {win.height}</p>
        <p>document - width: {doc.width}, height: {doc.height}</p>
      </div>
    );
  }
}

API

withWindowState(BaseComponent, options)

BaseComponent

Required

Type: ReactComponent

options.wait

Optional

Type: number

Default: 10

The number of milliseconds to throttle invocations to.

License

MIT © C.T. Lin

0.2.0

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago