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

188
Views
Can you use an export default function, with ReactToPrint?

I am trying to implement ReactToPrint, to print out the contents of the export default function ToDoList (Which returns a map of the Todo cards from another class).

 export default function ToDoList({ todos, toggleTodo }) {
  return todos.map((todo) => {
    return <Todo key={todo.id} toggleTodo={toggleTodo} todo={todo} />;
  });
}

The ReactToPrint library seems to prefer if you use a Class Component, or a functional component like below.

export const ComponentToPrint = React.forwardRef((props, ref) => {
return (
  <div ref={ref}>
    <h2>Grocery List Contents</h2>
  </div> 
); });

What is the best way that I could use the ToDoList Default Function, with ReactToPrint?

Thank you for your time.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I was able to figure it out. I just needed to add the desired element to a span tag, with a new ref variable slapped to it. That allowed the computer to see the component I desired.

function App() {
  const [todos, setTodos] = useState([]);
  const todoNameRef = useRef();
  const todoListRef = useRef();
);

 <span ref={todoListRef} class="containerClass">
        <ToDoList todos={todos} toggleTodo={toggleTodo}/>
        </span>
about 4 years ago · Juan Pablo Isaza Report
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!