Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
How to convert react-to-print libs into next js

I try to use react-to-print in next js but lib is for react here is what I'm trying to do

here is my index.tsx

import PrintComponent from './PrintComponent';
const Index = ()  => {
  return (
    <>
      <ReactToPrint trigger={() => <button>Print this out!</button>} content={() => React.componentRef} />
      <div className="hidden">
        <PrintComponent ref={el => (React.componentRef = el)} />
      </div>
    </>
  );
};

export default Index;

I try to import PrintComponent here is my PrintComponent

export function PrintComponent() {
  return (
    <div>
      <p>Count is: 1</p>
    </div>
  );
}

export default PrintComponent;

after I click button nothing happen but if I change my index.tsx

import { PrintComponent } from './PrintComponent';

and my PrintComponent look like this

export class PrintComponent extends React.Component {
  render() {
    return (
      <div>
        <p>Count is: 1</p>
      </div>
    );
  }

}

It's work!

anyone can help me explain how it's different and how can I convert them into next

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!