Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

worker.load is not a function #49

Description

@20b01a12b4

This is my App.js code when iam trying to run this iam getting this error "worker.load is not a fuction"!!

please resolve this !!

`import { useCallback, useEffect, useState } from 'react';
import { createWorker } from 'tesseract.js';
import './App.css';

function App() {
const [selectedImage, setSelectedImage] = useState(null);
const [textResult, setTextResult] = useState("");

const worker = createWorker();

const convertImageToText = useCallback(async () => {
if(!selectedImage) return;
await worker.load();
await worker.loadLanguage("eng");
await worker.initialize("eng");
const { data } = await worker.recognize(selectedImage);
console.log(data)
setTextResult(data.text);
}, [worker, selectedImage]);

useEffect(() => {
convertImageToText();
}, [selectedImage, convertImageToText])

const handleChangeImage = e => {
if(e.target.files[0]) {
setSelectedImage(e.target.files[0]);
} else {
setSelectedImage(null);
setTextResult("")
}
}
return (


Image to Text


Get words from image !!



upload image

  <div className='result'>
    {selectedImage && (
      <div className='box-image'>
        <img src={URL.createObjectURL(selectedImage)} alt="thumb" />
      </div>
    )}
    {textResult && (
      <div className='box-p'>
        <p>{textResult}</p>
        </div>
    )}
  </div>
</div>

);
}

export default App;`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions