# @focallabs/useful-react-hooks

> By Focal Labs

Latest version **1.0.4** (published 2019-07-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install @focallabs/useful-react-hooks
pnpm add @focallabs/useful-react-hooks
yarn add @focallabs/useful-react-hooks
bun add @focallabs/useful-react-hooks
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-07-29 |
| First published | 2019-07-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Luong Vu |
| Maintainers | joturako, kyonwow |

## Links

- npm: https://www.npmjs.com/package/@focallabs/useful-react-hooks
- npm.io page: https://npm.io/package/@focallabs/useful-react-hooks

## Dependencies (2)

- [suncalc](https://npm.io/package/suncalc.md) ^1.8.0
- [@types/suncalc](https://npm.io/package/@types/suncalc.md) ^1.8.0

## Recent versions

- 1.0.4 (latest) — 2019-07-29
- 1.0.3 — 2019-07-15
- 1.0.2 — 2019-07-15
- 1.0.1 — 2019-07-15
- 1.0.0 — 2019-07-15

## README

## Useful React Hooks

_For your own use, we do not take responsiblities_

![](https://img.shields.io/npm/dw/@focallabs/useful-react-hooks.svg)

## **useSunCalc**

This is a wrapper to get sunrise and sunset times using `SunCalc`

### Usage

> `useSunCalc(curDate?: Date, lat: number, lng: number, updateFreq: number) => {times: GetTimesResult, isNightLight: boolean}`

Provide the **current date**, **latitude** and **longitude** of a location, this hook will return a `GetTimesResult` object as seen [here](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/suncalc/index.d.ts) and a `isNightLight` boolean allow you to switch the theme of the app based on this variable value.

If `curDate` is omitted, the data will be refresh every second (or `updateFreq`). If `isNightLight` changes it's value, the app will be re-rendered, this allows you to change the theme of the app when the time come.

## Change log

### 1.0.4: Add `updateFreq` param (in miliseconds)

### 1.0.1: Add typing for typescript

### 1.0.0: First release

## Contribute

If you find something need to be changed, feel free to make a PR.

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