Quiero generar un pdf basado en accesorios de la interfaz de usuario y descargarlo.
Los datos de accesorios se obtendrán de una API después de hacer clic en el botón
Tener un documento como este.
const MyDoc = ({ text = "default" }) => { return ( <Document> <Page> <Text>dsdsds{text}</Text> </Page> </Document> ); }; const [text, setText] = useState("state"); function change(){ setText("updateText") } return ( <> <PDFViewer width="100%" height="850px"> <MyDoc text={{text}}/> </PDFViewer> <button onClick={change}>change props</button> </> ); }; const [text, setText] = useState("state"); function change(){ setText("updateText") } return ( <> <BlobProvider document={<MyDoc text={{text}}/>} > {({ url }) => ( <a href={url} target="_blank" rel="noreferrer noopener" > <b>Go to PDF</b> </a> )} </BlobProvider> <button onClick={change}>change props</button> </> ); }; const blob = pdf(MyDoc).toBlob(); //how can I add props to MyDoc const [instance, updateInstance] = usePDF({ document: MyDoc }); //how can I add props to MyDoc function change(){ updateInstance({ document: MyDoc }); } if (instance.loading) return <div>Loading ...</div>; if (instance.error) return <div>Something went wrong: {error}</div>; return ( <> <a href={instance.url} download="test.pdf"> Download </a> <button onClick={change}>change props</button> </> );¿O hay alguna otra forma más simple con react-pdf o estoy usando reaccionar mal, muchas gracias?