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

252
Views
error: no se pueden establecer propiedades de indefinido al establecer el valor del objeto anidado

Quiero establecer el valor de los errors en

 { email: { primary:"abc@gmail.com" } }

Después de compilar, devuelve un error:

 Cannot set properties of undefined (setting 'primary')

Aplicación.js

 import "./styles.css"; import { useState, useEffect } from "react"; export default function App() { const [errors, setErrors] = useState({}); useEffect(() => { const newErrors = errors; newErrors.email.primary = "abc@gmail.com"; }, []); return ( <div className="App"> <h1>Hello CodeSandbox</h1> <h2>Start editing to see some magic happen!</h2> </div> ); }

Códigosycaja:
https://codesandbox.io/s/immutable-http-w0mue?file=/src/App.js

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

0

Porque newErrors.email no está undefined . Solo actualiza así:

 newErrors.email = { primary: "abc@gmail.com" };
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!