-
-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript > Functional component > Example #401
Comments
Hello. Can you show your code without the error boxes? Specifically, how did you define the generic that |
const MyView: React.FC<IMyView> = (props) => {
const componentRef = React.useRef();
return React.useMemo(() => {
<>
<ReactToPrint trigger={() => (<div>PRINT</div>)} content={() => componentRef.current} />
<div>Print this</div>
</>
});
} |
|
Thanks @MatthewHerbst, it compiles now however a subsequent error fires when printing:
|
That's a correct error. You never assign the ref to anything. You need to do: |
That is it @MatthewHerbst, thanks for the support and please remember to update the docs. |
@michaelpeterlee PRs are welcome 😄 |
If the component to be printed is wrapped in a div, the ref should be placed inside the div and not the component itself. |
React: 16.14.0
Typescript is not happy, below. Can someone please provide an example implementation.
The text was updated successfully, but these errors were encountered: