jamenamcinteer / react-qr-barcode-scanner

A simple React Component using the client's webcam to read barcodes.
75 stars 74 forks source link

Property 'text' is private and only accessible within class 'Result' #16

Closed mrjelveh closed 3 years ago

mrjelveh commented 3 years ago

I have an issue when I'm using this library with typescript. When I wanted to use the object of result, I've got this TS error:

Property 'text' is private and only accessible within class 'Result'

I can't access to @zxing/library types because it's private. So how can I fix this type issue?

DavidRojas1612 commented 3 years ago

use the result.getText() method

            <BarcodeScannerComponent
              width={500}
              height={500}
              torch={torch}
              facingMode="environment"
              onUpdate={(err, result) => {
                if (result) {
                  handleResult(result.getText());
                }
              }}
            />
mrjelveh commented 3 years ago

Thanks it works