# @focusinlab/react-hook-useratio

> Custom hook to calculate aspect and assign height.

Latest version **1.0.1** (published 2021-05-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @focusinlab/react-hook-useratio
pnpm add @focusinlab/react-hook-useratio
yarn add @focusinlab/react-hook-useratio
bun add @focusinlab/react-hook-useratio
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-05-01 |
| First published | 2021-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 582.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | focus-in-lab |
| Maintainers | focusinlab |

## Links

- npm: https://www.npmjs.com/package/@focusinlab/react-hook-useratio
- Repository: https://github.com/focus-in-lab/react-hook-useratio
- Homepage: https://github.com/focus-in-lab/react-hook-useratio#readme
- Issues: https://github.com/focus-in-lab/react-hook-useratio/issues
- npm.io page: https://npm.io/package/@focusinlab/react-hook-useratio

## Recent versions

- 1.0.1 (latest) — 2021-05-01
- 1.0.0 — 2021-05-01

## README

# useratio

> Custom React hook to calculate aspect and assign height.

[![NPM](https://img.shields.io/npm/v/@focusinlab/react-hook-useratio.svg)](https://www.npmjs.com/package/@focusinlab/react-hook-useratio) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save @focusinlab/react-hook-useratio
```

## Usage

```jsx
import * as React from 'react'

import { useRatio } from '@focusinlab/react-hook-useratio'

const Example = ({ children }) => {
  const ref = useRef(null)
  const { height } = useRatio(1, 1, ref)
  useEffect(() => {
    if (ref.current) {
      ref.current.style.height = height + 'px'
    }
  }, [height, ref])

  return (
    <div
      ref={ref}
      onClick={() => console.log('clicked!')}
      style={{
        color: '#333',
        display: 'flex',
        boxSizing: 'border-box',
        alignItems: 'center',
        justifyContent: 'center',
        appearance: 'button',
        width: '100%'
      }}
    >
      {children}
    </div>
  )
}
```

## License

MIT © [focus-in-lab](https://github.com/focus-in-lab)

---

This hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).

---
_Source: https://npm.io/package/@focusinlab/react-hook-useratio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
