Comments (4)
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.
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.
Sorry for missing your last comment @Axion741. Were you able to resolve your issue?
from html-react-parser.
Closing issue due to inactivity. Feel free to reopen if there are any new updates.
from html-react-parser.
Related Issues (20)
- How to get the text from my html element with replace HOT 2
- Webpack workaround no longer working from 1.4.6 HOT 14
- Curly Brace Symbol Doesn't Show HOT 12
- Failed to parse source map from file HOT 1
- Vercel Edge not Supported HOT 2
- Type errors with v5.0.0 HOT 4
- version 5.0.1 cannot work with vite HOT 10
- Upgrading to latest version 5.0.3 throws compiling error: Can't reexport the named export 'Comment' from non EcmaScript module (only default export is available) HOT 8
- Nothing is parsed after an iframe HOT 2
- attributesToProps converts attribute with key name "open" always to value `true` HOT 2
- Warning with nextjs use - Extra attributes from the server HOT 3
- If the htmlString is dynamic and contains custom components (with hooks used), an error will be hanpend HOT 1
- missing type for domNode.children HOT 4
- Issue after 5.0.9 update HOT 3
- Cannot Handle Microsoft Meeting Link HOT 3
- Add Current Node Index in `replace` Callback HOT 6
- Replacing domNode with editor element multiple times breaks editor bubble menu HOT 4
- Method transform has wrong current index HOT 5
- Validate props beforing passing the props object to the element HOT 3
- SVG html with large Data URL returns empty SVG code HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html-react-parser.