React mixin which sets width as state variable and updates as component changes shape
Clone or download
Latest commit 12dbef1 Oct 10, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Oct 6, 2014
LICENSE Initial commit Oct 6, 2014
Makefile Initial commit Oct 6, 2014
README.md Update README.md Nov 7, 2014
index.js c.getDOMNode -> ReactDOM.findDOMNode(c) Oct 9, 2015
package.json 2.0.0 Oct 9, 2015

README.md

react-component-width-mixin

React mixin which detects when component resizes and sets the new width as a state variable

Install

npm install react-component-width-mixin

Usage

var componentWidthMixin = require('react-component-width-mixin');

React.createClass({
  mixins: [componentWidthMixin],
  
  render: function() {
    // Now the component width is available after the initial render
    // as this.state.componentWidth.
  }
});

If you'd like to set an initial width for your component (e.g. server-side rendering), pass in a prop called initialComponentWidth.