1.0.4 • Published 6 years ago
@focallabs/useful-react-hooks v1.0.4
Useful React Hooks
For your own use, we do not take responsiblities
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 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.