I have a component that I'm trying to print using react-to-print, is there any way I can print this component duplicated in one page?
here is my code:
import React, {useRef} from 'react';
import { useReactToPrint } from 'react-to-print';
import MyComponent from './myComponent';
import OtherComponent from './otherComponent';
const CreateAtt = () => {
const componentRef = useRef();
const printData = useReactToPrint({
content: () => componentRef.current,
documentTitle: 'doc',
});
return (
<>
<div className='d-flex justify-content-between'>
<div ref={componentRef}>
<MyComponent />
</div>
<OtherComponent />
</div>
<button className='btn btn-primary download-button' onClick={printData}>print</button>
</>
)
}
export default CreateAtt;