import React from 'react';
import ReactDOM from 'react-dom';
//JavaScript Expressions in JSX in REACT
//we can only use expression inside'{}', can't use statements
const tech1 = "REACT";
const tech2 = "JS";
console.log(`This is ${tech1}`)//ES6 Template Literals in JSX
ReactDOM.render(
<>
<h1>Welcome to {tech1+" "+tech2}</h1>
<h2>{`This is ${tech1} ${tech2}`}</h2>
<p>JavaScript Expressions in JSX</p>
<h3>Sum of three values(34+3+0) is {34+3+0}</h3>
</>,
document.getElementById('root')
);
Date/Time Methods:
const currentDate = new Date().toLocaleDateString();
const currentTime = new Date().toLocaleTimeString();
JSX attributes:
import React from 'react';
import ReactDOM from 'react-dom';
const tech1 = "REACT";
const img1 = "https://picsum.photos/200";
const link = "https://www.webruchi.in/";
ReactDOM.render(
<>
<h1 contentEditable="true">Welcome to {tech1}</h1>
<img src={img1} alt="dummyImage"/>
<a href={link} traget="_blank">
<img src={img1} alt="dummyImage"/>
</a>
</>,
document.getElementById('root')
);
No comments:
Post a Comment