Giter Site home page Giter Site logo

Comments (4)

remarkablemark avatar remarkablemark commented on May 13, 2024

Hi @Axion741, are you properly using template literals (template strings) here?

// regular string
'<img src={require("./img/articles/2019/1/react.png")}></img>';

// template string
`<img src="${require("./img/articles/2019/1/react.png")}">`

The regular string will stringify the require statement whereas the string template will interpolate the require value.

Also, like you shown in your last example, the img tag is a void element so it should be self-closing:

// good
<img src="file.png">
<img src="file.png" />

// bad
<img src="file.png"></img>

If I'm misunderstanding your issue, could you please reproduce it in a CodeSandbox?

from html-react-parser.

Axion741 avatar Axion741 commented on May 13, 2024

Well now I'm at even more of a loss.
With the fixed template strings, my HTML parses perfectly in the sandbox, but the image is still broken for me in my app.
The rest of the HTML pops out fine, but the Img tag still parses to this;
<img src="${require('./img/articles/2019/1/react.png')}">
Instead of interpolating the require.

from html-react-parser.

remarkablemark avatar remarkablemark commented on May 13, 2024

Sorry for missing your last comment @Axion741. Were you able to resolve your issue?

from html-react-parser.

remarkablemark avatar remarkablemark commented on May 13, 2024

Closing issue due to inactivity. Feel free to reopen if there are any new updates.

from html-react-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.