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

112
Views
TypeError: no se puede desestructurar la propiedad 'posición' de 'indefinido' ya que no está definido

Estoy pasando una función que cambia los estados del componente principal al segundo componente y luego del segundo componente al tercer componente y llamo desde allí.

Esto da como resultado el siguiente error:

TypeError: no se puede desestructurar la propiedad 'posición' de 'indefinido' ya que no está definido

El siguiente es mi código de referencia:

 export class ParentComponent extends Component { constructor(props) { super(props); this.state = { address: '', position: { lat: 0, lng: 0, }, }; this.locationChangeHandler = this.locationChangeHandler.bind(this); } locationChangeHandler({ position, address, places }) { // Set new location this.setState({ position, address }); } render(){ <SecondComponent locationChangeHandler={this.locationChangeHandler}/> }

Segundo Componente:

 <ThirdComponent locationChangeHandler={locationChangeHandler}/>

Tercer Componente:

 <FourthComponent onChange={locationChangeHandler()}/>

¿Cómo resuelvo esto? Soy relativamente nuevo en ReactJs y agradecería toda ayuda.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

¿Puedes cambiar la función locationChangeHandler de esta manera?

 locationChangeHandler(loc) { // Set new location if(loc && loc.position && loc.address) this.setState({ position: loc.position, address: loc.address }); }
about 4 years ago · Santiago Gelvez 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!