puffinsoft / jscanify

Open-source Javascript mobile document scanner.
https://puffinsoft.github.io/jscanify/
MIT License
949 stars 52 forks source link

Error importing jscanify library in React application #26

Closed Hadi311374 closed 1 month ago

Hadi311374 commented 5 months ago

I'm experiencing an issue when trying to import and use the jscanify library in a React application. While the CDN approach works fine, importing the library as a module using the import statement causes an error.

import React, { useEffect, useRef, useState } from 'react'; import jscanify from 'jscanify';

export default function PaperScanner() { const canvasRef = useRef(null); const [photoData, setPhotoData] = useState(null);

useEffect(() => { const scanner = new jscanify(); // <-- Error occurs here

}, []);

}

Error Message: TypeError: Cannot set property document of # which has only a getter

ColonelParrot commented 5 months ago

It has to be imported through the html file. See react-scanify-demo

Hadi311374 commented 5 months ago

In this use CDN

ColonelParrot commented 1 month ago

Yes, unfortunately I haven't had the opportunity to add React support 😔