Reputation: 234
**** So this is what terminal shows me ****
./src/card.js
Line 9:9: Parsing error: Unterminated JSX contents
7 | <h2>john doe</h2>
8 | <p>[email protected]</p>
> 9 | </div>
| ^
10 | );
11 | }
12 | export default card;
**** this is the code that i'm running using react, I don't why its showing error even though i have enclose it properly****
1.This is card.js file -->
import React from 'react';
const card=()=>{
return(
<div>
<img src="" alt="roboIMG">
<h2>john doe</h2>
<p>[email protected]</p>
</div>
);
}
export default card;
2.This is index.js code-->
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import card from './card';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<card/>, document.getElementById('root'));
serviceWorker.unregister();
Upvotes: 0
Views: 63
Reputation: 11622
your <img>
tag need to be closed:
import React from 'react';
const card=()=>{
return(
<div>
<img src="" alt="roboIMG" />
<h2>john doe</h2>
<p>[email protected]</p>
</div>
);
}
export default card;
check out this documentation on JSX
Upvotes: 0
Reputation: 1014
Your code have an error as in react you just can't use img
tag without closing it as its not a simple html. You have to close it like <img src="" alt="roboIMG" />
Upvotes: 1
Reputation: 1341
Yout <img src="" alt="roboIMG">
tag doesnot have a closing jsx.
use <img src="" alt="roboIMG" />
its a self-closing tag element.
Upvotes: 3