React mixin which sets width as state variable and updates as component changes shape
Clone or download
Latest commit 12dbef1 Oct 10, 2015
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 Update Nov 7, 2014
index.js c.getDOMNode -> ReactDOM.findDOMNode(c) Oct 9, 2015
package.json 2.0.0 Oct 9, 2015


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


npm install react-component-width-mixin


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

  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.