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

404
Views
Error al usar la biblioteca xml2js con React y TypeScript

Tengo una aplicación React que necesita analizar algunos datos XML. Planeo usar un paquete para hacer este trabajo. Los paquetes xml2js y @types/xml2js están instalados. Durante la prueba apareció el siguiente error:

 sax.js:222 Uncaught TypeError: Cannot read properties of undefined (reading 'prototype') at sax.js:222:46 ...

Aquí está el archivo que contiene el código. La sintaxis debe ser correcta de acuerdo con los documentos. Los otros componentes no deberían causar este error en particular, ya que aún no están conectados.

 import {useState, useEffect} from 'react' import x2j from 'xml2js'; export default function EventWindow(props: { xml: string; }) { const {xml} = props; const [eventText, setEventText] = useState(''); const [eventChoices, setEventChoices] = useState(''); useEffect(() => { const ps = new x2j.Parser(); ps.parseString(xml, (err, res) => { console.log(res) }) }, [xml]) return ( <div> <EventSimText text={eventText || "Error Detected."} /> <EventSimChoices choicesArr={eventChoices} /> </div> ) }

Gracias

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

0

Se requieren detalles del problema antes de corregirlo. Por ejemplo, capturas de pantalla 🔍

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!