react-to-pdf icon indicating copy to clipboard operation
react-to-pdf copied to clipboard

The toPDF function in usePDF should return a Promise object

Open itouchzh opened this issue 1 year ago • 0 comments

Hello, I believe the type of toPDF should not be void, but rather a promise. This way, we can utilize the Promise to access subsequent states and related functions, enabling us to perform more operations.

type UsePDFResult = {
    /**
     * React ref of the target element
     */
    targetRef: MutableRefObject<any>;
    /**
     * Generates the pdf
     */
    toPDF: (options?: Options) => void;
};

change

type UsePDFResult = {
    /**
     * React ref of the target element
     */
    targetRef: MutableRefObject<any>;
    /**
     * Generates the pdf
     */
    toPDF: (options?: Options) => Promise<InstanceType<typeof jsPDF>>;
};

itouchzh avatar Dec 28 '23 02:12 itouchzh