Need Help With React Development?

Work with our skilled React developers to accelerate your project and boost its performance.

Hire Reactjs Developers

Support On Demand!

In order to resolve the error “TypeError: Cannot read property ‘getBoundingClientRect’ of null”, you’ll need to make some adjustments in your code. Specifically, ensure that ‘pdfWrapper’ exists and has a ‘current’ property before using it, as demonstrated in the below code snippet:

const setPdfSize = () => {
   // check if 'pdfWrapper' exists and has a 'current' property before using it
    if (pdfWrapper?.current) { 
      setInitialWidth(pdfWrapper.current.getBoundingClientRect().width);
    }
  };

Related Q&A