React-to-print: How Can i Print?

Created on 9 Nov 2018  路  9Comments  路  Source: gregnb/react-to-print

BAD DOCS BAD DOCS BAD DOCS BAD DOCS
What is componentRef?

question

Most helpful comment

I read the document but I still can not understand how I can define the componentRef.
and I have another question, I'm using FabricUI Dialog component, can I print the content of the dialog?

All 9 comments

How Can i Pass a function that return a div and h2 to print it?

is ComponentToPrint must be an Class?

@ikosar yes. The library requires the use of refs to work, and functional components do not have refs.

From the React docs:

You may not use the ref attribute on function components because they don鈥檛 have instances.

If you know of a better way to write this library that without refs we'd be happy to hear it. Thanks!

Dear MatthewHerbst
Many thanks to your complete answer

I read the document but I still can not understand how I can define the componentRef.
and I have another question, I'm using FabricUI Dialog component, can I print the content of the dialog?

@AhmadiRamin what don't you understand? It's just any React ref.

@MatthewHerbst Thanks Matthew, I figured it out and it's working now.

@ikosar are you still having problems?

Was this page helpful?
0 / 5 - 0 ratings