|
1 | | -function MyComponent({width, height}) { |
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var _extends = |
| 4 | + Object.assign || |
| 5 | + function(target) { |
| 6 | + for (var i = 1; i < arguments.length; i++) { |
| 7 | + var source = arguments[i]; |
| 8 | + for (var key in source) { |
| 9 | + if (Object.prototype.hasOwnProperty.call(source, key)) { |
| 10 | + target[key] = source[key]; |
| 11 | + } |
| 12 | + } |
| 13 | + } |
| 14 | + return target; |
| 15 | + }; |
| 16 | + |
| 17 | +function _objectWithoutProperties(obj, keys) { |
| 18 | + var target = {}; |
| 19 | + for (var i in obj) { |
| 20 | + if (keys.indexOf(i) >= 0) continue; |
| 21 | + if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; |
| 22 | + target[i] = obj[i]; |
| 23 | + } |
| 24 | + return target; |
| 25 | +} |
| 26 | + |
| 27 | +function MyComponent(_ref) { |
| 28 | + var width = _ref.width, |
| 29 | + height = _ref.height, |
| 30 | + getRef = _ref.getRef, |
| 31 | + children = _ref.children, |
| 32 | + props = _objectWithoutProperties(_ref, [ |
| 33 | + 'width', |
| 34 | + 'height', |
| 35 | + 'getRef', |
| 36 | + 'children', |
| 37 | + ]); |
| 38 | + |
2 | 39 | return React.createElement( |
3 | 40 | 'div', |
4 | | - {className: 'example'}, |
| 41 | + _extends({className: 'example', ref: getRef}, props), |
5 | 42 | "Hover me! I don't rely on any DOM manipulation, transition event or anything, I use a real resize event!", |
6 | 43 | React.createElement('br', null), |
7 | | - `${width}x${height}` |
| 44 | + width, |
| 45 | + 'x', |
| 46 | + height, |
| 47 | + children |
8 | 48 | ); |
9 | 49 | } |
10 | 50 |
|
11 | 51 | function App() { |
12 | | - return React.createElement( |
13 | | - ReactResizeAware, |
14 | | - { |
15 | | - style: {position: 'relative'}, |
16 | | - onResize(sizes) { |
17 | | - console.log(sizes); |
18 | | - }, |
| 52 | + return React.createElement(ReactResizeAware, { |
| 53 | + component: MyComponent, |
| 54 | + useBoundingClientRect: true, |
| 55 | + style: {position: 'relative'}, |
| 56 | + onResize: function onResize(sizes) { |
| 57 | + return console.log(sizes); |
19 | 58 | }, |
20 | | - React.createElement(MyComponent, null) |
21 | | - ); |
| 59 | + }); |
22 | 60 | } |
23 | 61 |
|
24 | 62 | ReactDOM.render( |
|
0 commit comments