<div> contains <img>,Can't display images
See original GitHub issue“react-native”: “0.48.3” “react-native-htmlview”: “^0.12.0” android:7.0
here is my code:
render() {
const htmlContent = `
<div>
<img src="http://d.lanrentuku.com/down/png/1504/bianping-yuanicon/bianping-yuanicon-09.png" />
</div>
`;
return (
<View>
<HTMLView
value={htmlContent}
/>
</View>
);
}
If use <div> containing < img>, will not be able to display the image.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top Results From Across the Web
Image inside div doesn't show - Stack Overflow
How to fix it: To fix this, you need to set your width and height to actual values, so that there is an...
Read more >The IMG (Image) Element
Browsers that cannot display in-line images ignore the IMG element unless it contains the ALT attribute. Note that some browsers can display (or...
Read more >Using the image tag in React - Dave Ceddia
How do you refer to an image in React? The img tag is a bit weird. Learn how to include images in your...
Read more >Responsive images - Learn web development | MDN
The content images have been set so that if the body element becomes smaller than the image, the images start to shrink so...
Read more >How to fix CSS background-image not working | HTML/CSS
If there is no HTML content in the element, it might have zero width or height (or both!). This means that even though...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to add another function named renderNode():
and then change HTMLView tag like this:
<HTMLView value={htmlContent} renderNode={this.renderNode} />
That’s all. Your renderNode() function and render() function should be siblings at that example. @Ctonys
Hello guys, this is my code. I hope it can help you
PixelRatio.get()
returns the device pixel density.