🚀 Socket Launch Week 🚀 Day 3: Socket Acquires Coana.Learn More
Socket
Sign inDemoInstall
Socket

@blackbox-vision/use-torch-light

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blackbox-vision/use-torch-light

A hook to enable/disable camera flash

0.0.2
latest
Source
npm
Version published
Weekly downloads
622
-43.61%
Maintainers
2
Weekly downloads
 
Created
Source

UseTorchLight npm version License: MIT Known Vulnerabilities

🔦 useTorchLight is a hook to enable/disable camera flash. Check out the demo.

Install

You can install this library via NPM or YARN.

NPM

npm i @blackbox-vision/use-torch-light

YARN

yarn add @blackbox-vision/use-torch-light

Usage

The usage is really simple:

import React, { useState, useRef } from 'react';
import { QrReader } from '@blackbox-vision/react-qr-reader';
import { useTorchLight } from '@blackbox-vision/use-torch-light';

const Test = (props) => {
  const streamRef = useRef(null);

  const [error, setError] = useState(null);
  const [data, setData] = useState('No result');

  const [on, toggle] = useTorchLight(streamRef.current);

  const setRef = ({ stream }) => {
    streamRef.current = stream;
  };

  return (
    <>
      <QrReader
        onLoad={setRef}
        onScan={setData}
        onError={setError}
        style={{ width: '100%' }}
      />
      <button onClick={toggle}>{on ? 'Disable Torch' : 'Enable Torch'}</button>
      <p>{JSON.stringify(data, null, 2)}</p>
      <p>{JSON.stringify(error, null, 2)}</p>
    </>
  );
};

Issues

Please, open an issue following one of the issues templates. We will do our best to fix them.

Contributing

If you want to contribute to this project see contributing for more information.

License

Distributed under the MIT license. See LICENSE for more information.

Keywords

react

FAQs

Package last updated on 24 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts