Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda