react-native-orient
v1.3.3
Published
higher order component that responds to orientation changes and passes down new props
Downloads
17
Readme
Install
npm install --save react-native-orient
Usage
import { makeResponsive, getDimensions } from 'react-native-orient'
export class PortraitLockedComponent extends React.Component {
static orientation = 'portrait';
render() {
const dim = getDimensions(PortraitLockedComponent)
return (
// ...
)
}
}
class ResponsiveComponent extends React.Component {
render() {
// will rerender when orientation / dimensions change
// this.props = {
// ..
// orientation: 'portrait', // or 'landscape'
// dimensions: { width, height }
// }
const dim = this.props.dimensions
return (
// ...
)
}
}
ResponsiveComponent = makeResponsive(ResponsiveComponent)
export ResponsiveComponent