mirror of
https://github.com/camflan/light-sensor.git
synced 2026-06-20 21:59:02 +00:00
Ambient Light Sensor hook for React
- JavaScript 82.2%
- HTML 17.8%
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.15) Signed-off-by: dependabot[bot] <support@github.com> |
||
|---|---|---|
| .gitignore | ||
| .travis.yml | ||
| example.html | ||
| example.js | ||
| index.d.ts | ||
| index.js | ||
| index.js.flow | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| test-setup.js | ||
| test.js | ||
| yarn.lock | ||
@rehooks/light-sensor
React hook for subscribing to the readings of your device's AmbientLightSensor
Note: At the moment, browser support is thin and also requires use of Feature-Policy headers
Note: This is using the new React Hooks API Proposal which is subject to change until React 16.7 final.
You'll need to install
react,react-dom, etc at^16.7.0-alpha.0
Install
yarn add @rehooks/light-sensor
Usage
import useAmbientLightSensor from '@rehooks/light-sensor';
function MyComponent() {
let lux = useAmbientLightSensor();
if(lux == null) { return "Loading" }
return <div>{`You're device is reading ${lux} lux`}</div>;
}