When I am working with many images to print
You would want to setup a Promise.all to wait on the images to load, and then feed that into the return of onBeforePrint
Let me ask in another way. How to check content contains something to print ?
My code is working fine on my computer. But when I run in another machine it is printing empty page at first and when I click cancel and click print then it is working fine.
You would have to share some code for me to see specifically what you are talking about. However, again, to load any resource prior to printing, return a Promise in onBeforePrint. This library does not know what you are printing. If you are loading async resources in the print window you have to ensure they are loaded before printing continues.
I have just recognized. it is not working when I change anchor tag to button inside trigger.
But it's working on CondeSandbox example when I have changed to button.
<Fragment>
<div style={{ display: "none" }}>
<ComponentToPrint
data={this.props.dataForPdf}
fdate={this.props.from_date}
tdate={this.props.to_date}
ref={el => (this.componentRef = el)}
/>
</div>
<ReactToPrint
trigger={() => <button className="onlya">小泻邪褔邪褌褜 PDF</button>}
content={() => this.componentRef}
/>
</Fragment>