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

172
Views
Integre un proyecto JavaScript a un proyecto ReactJS existente

Quiero integrar este repositorio a mi proyecto react.js existente https://github.com/zoltan-dulac/Matrix-Construction-Set . El proyecto Matrix-Construction-Set tiene muchos archivos Javascript y algunos paquetes bower que deben estar presentes para que funcione correctamente. He instalado Bower y tengo todos los paquetes en /bower_components que están al mismo nivel que /node_modules . En el proyecto Matrix-Construction-Set , todos los archivos js se incluyen como <script/> después de la etiqueta <body/> . Estoy usando un enlace personalizado que agrega todas esas etiquetas con src al dom de la siguiente manera.

gancho personalizado

 import { useEffect } from 'react'; const useScript = url => { useEffect(() => { const script = document.createElement('script'); script.src = url; script.async = true; document.body.appendChild(script); return () => { document.body.removeChild(script); } }, [url]); }; export default useScript;

Hay muchos archivos js que están incluidos y a continuación se muestra solo un ejemplo de cómo lo hago dentro de un componente funcional. Lo he comprobado y todos los scripts se agregan al dom .

 useScript('../../../../assets/augmented3dmatrix/js/kmewhort/pointer_events_polyfill.js'); useScript('bower_components/visibleIf/shared/js/visibleIf.js'); useScript('bower_components/html5Forms/shared/js/EventHelpers.js'); useScript('bower_components/dialog-polyfill/dist/dialog-polyfill.js');

Por ahora, recibo errores de undefined en el archivo visibleIf.js .

 src\assets\augmented3dmatrix\js\visibleIf.js Line 241:41: 'EventHelpers' is not defined no-undef Line 488:41: 'url' is not defined no-undef Line 488:47: 'config' is not defined no-undef Line 492:76: 'url' is not defined no-undef Line 576:31: 'ReadyState' is not defined no-undef Line 580:31: 'HttpCode' is not defined no-undef Line 580:60: 'HttpCode' is not defined no-undef Line 672:18: 'j' is not defined no-undef

¿Cómo agrego paquetes de Bower para que el archivo js tenga acceso a ellos?

SI alguien conoce una nueva herramienta similar, por favor hágamelo saber.

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

0

Intente agregar etiquetas <script/> en el archivo index.html .

about 4 years ago · Juan Pablo Isaza Report

0

Recomendaría bifurcar el repositorio y mejorar la estructura del código. Si tiene varias funciones que necesita, es mejor crear un paquete npm. Hay algunas instrucciones aquí en https://www.section.io/engineering-education/npm-packages/

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!