1.3.1 • Published 5 years ago

@21kb/react-device-orientation-hook v1.3.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

@21kb/react-device-orientation-hook

React hook for subscribing to the deviceorientation event

Install

npm

npm install --save @21kb/react-device-orientation-hook

Yarn

yarn add @21kb/react-device-orientation-hook

Usage

import useOrientation from '@21kb/react-device-orientation-hook';

// import App from './App';
// import {Col, Container, Grid, Row} from './Grid';

const Component = () {
  const state = useOrientation({
    angle: 0,
    type: 'landscape-primary',
  });
  const {angle, type} = state;

  return (
    <Container fluid>
      {if (type === 'landscape-primary') {
        <Grid lg>
          <Row>
            <Col />
            <Col />
            <Col />
          </Row>
        </Grid>
      } else {
        <Grid sm>
          <Row>
            <Col />
            <Col />
            <Col />
          </Row>
        </Grid>
      }}
    </Container>
  );
};

License

MIT

1.3.1

5 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago