1.0.7 • Published 4 years ago

react-qr-hooks v1.0.7

Weekly downloads
18
License
MIT
Repository
github
Last release
4 years ago

react-qr-hooks

NPM version NPM downloads

About

Encode & decode QR code in React

How to Install

First, install the library in your project by npm:

$ npm install react-qr-hooks

Or Yarn:

$ yarn add react-qr-hooks

Getting Started

• Import hooks in React application file:

import { useQrEncode, useQrDecode } from 'react-qr-hooks';

useQrEncode

Options

NameTypeDefaultDescription
textstringText to encode
optionsQRCodeToDataURLOptions{}Options for qrcode library

Returned Values

TypeDescription
stringEncoded value

useQrDecode

Options

NameTypeDefaultDescription
datastringAn image from url or an <img> element with a src attribute set
optionsobject{}Options for qrcode-decoder library

Returned Values

TypeDescription
stringvalue decoded from QR code

Example

import React from 'react';
import { useQrEncode, useQrDecode } from 'react-qr-hooks';

const App = () => {
  const encoded = useQrEncode('Hello world!', /* object with options (if needed) */);

  const decoded = useQrDecode(encoded, /* object with options (if needed) */);

  return (
    <>
      <img src={encoded} alt="My QR code" />
      <p>{decoded}</p>
    </>
  );
}

export default App;

License

This project is licensed under the MIT License © 2020-present Jakub Biesiada

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-beta.1

4 years ago