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

138
Views
Cómo reescribir un componente de clase con componentWillReceiveProps en un componente funcional

Estoy tratando de refactorizar este componente React en un componente funcional, pero no estoy muy seguro de cómo manejar la parte del componentWillReceiveProps . He buscado algunas guías y preguntas anteriores, pero no puedo encontrar nada sobre este aspecto específicamente.

 import React from "react"; class Thumbnail extends React.Component { state = { loading: false, thumb: undefined, }; componentWillReceiveProps(nextProps) { if (!nextProps.file) { return; } this.setState({ loading: true }, () => { let reader = new FileReader(); reader.onloadend = () => { this.setState({ loading: false, thumb: reader.result }); }; reader.readAsDataURL(nextProps.file); }); } render() { const { file } = this.props; const { loading, thumb } = this.state; if (!file) { return null; } if (loading) { return <p>loading...</p>; } return ( <img src={thumb} alt={file.name} className="img-thumbnail mt-2" height={200} width={200} /> ); } }
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!