JSX Elements
JSX stands for JavaScript XML.
Let's see how we can write JSX in our react application:
-To write JSX we wrap the element inside curly braces as
<p>Hello, {name}</p>
- To display content use double quotes as
<p>{"Hello world"}</p>
Example:
function Calculator(){
let num = 2;
return(
<div>
<p>Square of {num} is {num*num}</p>
{/*Using expressions*/}
<p>{num} is an {num%2:'Even':'Odd'}</p>
</div>
);
}
Comments
Post a Comment