`
function bannner() {
const title = "c'est pur 😎"
return (<h1>{title}</h1>)
}
function cart() {
const prixbedo = 10
const prixhero = 20
const prixcoc = 70
return (<div>
<h2>Panier</h2>
<ul>
<li>bedo : {prixbedo}$</li>
<li>heroïne : {pixhero}$</li>
<li>cocaïne : {prixcoc}$</li>
</ul>
</div>)
}
ReactDOM.render(<div><banner /><cart /></div>, document.getElementById("root"))
i declared my file .js in my file .html when I test with simple function is good I see on my website the result but with this code nothing happens
3
Answers
You need to create root.
You should not write the name of the tale in lowercase.
Causes an error in the function rendering.
Write as follows:
I think your component not showing up is because you used lower case to write your functions just like other people have pointed out. I just wanted to give more context.
According to the react docs here, in JSX, lower-case tag names are considered to be HTML tags. eg
<cart />
compiles to React.createElement(‘cart’) (html tag).<Cart />
compiles to React.createElement(Cart) (a react component)So because
<cart />
is not a recognised tag, it doesn’t show. Hope this helps