Search code examples
javascriptreactjspdfjspdf

jsPDF: A constructor name should not start with a lowercase letter


I'm trying to create a pdf in React

consy myComponent = () => {
   const pdfGenerator = () => {
      const doc = new jsPDF(); //I also tried: new jsPDF('landscape', 'px', 'a4', 'false');
      doc.text('Hello world',10,10)
      doc.save('name.pdf');
   }

  return (
     <button onClick={pdfGenerator} type='button'>Download</button>
  )

}

export default myComponent;

But I get A constructor name should not start with a lowercase letter. Even it's exactly like the example from official documentation. [https://www.npmjs.com/package/jspdf] What is wrong? Thanks in advance


Solution

  • From anyone who need it in the future: I've changed

    import jsPDF from 'jspdf';
    const doc = new jsPDF();
    

    to:

    import JsPDF from 'jspdf';
    const doc = new JsPDF();
    

    and everything works fine