forked from digidem/react-dimensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.jsx
39 lines (34 loc) · 852 Bytes
/
example.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { PropTypes } from 'react'
import ReactDom from 'react-dom'
import Dimensions from './index.jsx'
class MyComponent extends React.Component {
static propTypes = {
containerWidth: PropTypes.number.isRequired,
containerHeight: PropTypes.number.isRequired
}
render () {
return (
<div style={{
backgroundColor: 'LightGreen',
width: this.props.containerWidth,
height: this.props.containerHeight
}}>
{`${this.props.containerWidth}px x ${this.props.containerHeight}px`}
</div>
)
}
}
const EnhancedComponent = Dimensions()(MyComponent)
const div = document.createElement('div')
document.body.appendChild(div)
ReactDom.render((
<div style={{
position: 'absolute',
top: 20,
right: 50,
bottom: 20,
left: 50
}}>
<EnhancedComponent />
</div>
), div)