Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
Opening an external html file from a react app

I have a react app, which i make thought create-react-app. I want to make here a link, that will refer to project.html file. I tried to make something like this:

const Portfolio = (props) => {
    return (
            <a href="../projects/project.html" target="_blank">
                <button>Go to this project</button>
            </a>
    )
}

But this lead me to http://localhost:3000/projects/project.html and react app. I also tried to import this path like:

import html from "../projects/project.html"

and then to do something like this:

        <a href={html} target="_blank">
            <button>Go to this project</button>
        </a>

but react say that i need some loader for this. I find that there are html-loader, i install it by npm install --save-dev html-loader and add configuration to webpack.config.js but nothing changed

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If your projects/project.html file contains only static content and does not require anything from the codebase, you could move the projects folder to the public folder, and link to that file in your React component with:

const Portfolio = (props) => {
    return (
            <a href="/projects/project.html" target="_blank">
                Go to this project
            </a>
    )
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

First install html loader using

npm install --save-dev html-loader

Add below lines to your webpack.config file

{
  project: /\.(html)$/,
  use: {
    loader: 'html-loader',
    options: {
      attrs: [':data-src']
    }
  }
}

Now you can import like this

import Page from './project.html';
var htmlDoc = {__html: Page};

Then, in return block of react, use like this

<div dangerouslySetInnerHTML={htmlDoc} />
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda