Listen The Resize Event In React – react-resize-aware

A simple React.js component you can use to make any piece of UI aware of its size.

Each time the component’ size changes, your component will be notified by one of the methods described below. The size change can be detected by a window resize, a CSS media query, a CSS pseudo selector, a JavaScript action or really, anything.


# Yarn
$ yarn add react-resize-aware

$ npm install react-resize-aware --save

Basic Usage:

'use strict';

var _extends =
  Object.assign ||
  function(target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];
      for (var key in source) {
        if (, key)) {
          target[key] = source[key];
    return target;

function _objectWithoutProperties(obj, keys) {
  var target = {};
  for (var i in obj) {
    if (keys.indexOf(i) >= 0) continue;
    if (!, i)) continue;
    target[i] = obj[i];
  return target;

function MyComponent(_ref) {
  var width = _ref.width,
    height = _ref.height,
    getRef = _ref.getRef,
    children = _ref.children,
    props = _objectWithoutProperties(_ref, [

  return React.createElement(
    _extends({className: 'example', ref: getRef}, props),
    "Hover me! I don't rely on any DOM manipulation, transition event or anything, I use a real resize event!",
    React.createElement('br', null),

function App() {
  return React.createElement(ReactResizeAware.default, {
    component: MyComponent,
    style: {position: 'relative'},
    onResize: function onResize(sizes) {
      return console.log(sizes);

  React.createElement(App, null),


React Component For Accessible Sorting

Download Details:

Author: FezVrasta

Live Demo: View The Demo

Download Link: Download The Source Code

Official Website:

License: MIT

You Might Be Interested In:


Add Comment