admin管理员组文章数量:1389761
Hello Guys I am new to react and trying to clone Netflix through a youtube tutorial. So the issue here is that I am using an Image in a functional ponent, but it is not rendering properly
The error I am getting is this:
InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('/static/media/tab1.fab25bc3.png') is not a valid name.
This is my Functional Component code:
import React, { Component } from "react";
import Img from "../images/tab1.png";
export default function TabContentOne() {
return (
<div className="container">
<div className="tab-content">
<span>
If you decide Gamolytcs isn't for you - no problem. No mitment.
Cancel online anytime.
<br />
<button>Try it now</button>
<Img src={Img} alt="" />
</span>
</div>
</div>
);
}
Hello Guys I am new to react and trying to clone Netflix through a youtube tutorial. So the issue here is that I am using an Image in a functional ponent, but it is not rendering properly
The error I am getting is this:
InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('/static/media/tab1.fab25bc3.png') is not a valid name.
This is my Functional Component code:
import React, { Component } from "react";
import Img from "../images/tab1.png";
export default function TabContentOne() {
return (
<div className="container">
<div className="tab-content">
<span>
If you decide Gamolytcs isn't for you - no problem. No mitment.
Cancel online anytime.
<br />
<button>Try it now</button>
<Img src={Img} alt="" />
</span>
</div>
</div>
);
}
Share
Improve this question
asked Mar 7, 2020 at 6:21
SMAmmar14SMAmmar14
291 silver badge7 bronze badges
1 Answer
Reset to default 7Your tag and imported png share the same name
alter the code to use a lowercase tag
<img src={Img} alt="" />
or change your import to be a different name to avoid the confusion and make it a little clearer and prevent autopletes or suggestions in the IDE from tripping you up :)
import TabImg from "../images/tab1.png";
and then do this so its clearer what is what
<img src={TabImg} alt="" />
本文标签:
版权声明:本文标题:javascript - InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag nam 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744645477a2617376.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论