ivmarcos / react-to-pdf

Generate pdf from react components
MIT License
282 stars 62 forks source link

The toPDF function in usePDF should return a Promise object #106

Open itouchzh opened 10 months ago

itouchzh commented 10 months ago

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>>;
};