1react Intro AppCreation
1react Intro AppCreation
In React, you write code that looks like HTML right in your
JavaScript code.
</div>
</body>
</html>
React Components
- React is component based.
- Components are building blocks for react application.
- Component is combination of
o Logic
o Presentation and
o Styles
- Logic is defined using JavaScript
- Presentation is defined by using HTML
- Styles are defined by using CSS
- In react components can be designed by using
o JavaScript functions
o JavaScript classes
- React components are classified into 2 types
o Function Components [JavaScript Functions]
o Class Components [JavaScript Classes]
</div>
</body>
</html>
Ex: Function Component as Arrow function
<!DOCTYPE html>
<html>
<head>
<title>React Demo</title>
<link rel="stylesheet"
href="../node_modules/bootstrap/dist/css/bootstrap.css">
<script src="../node_modules/react/umd/react.development.js"></script>
<script src="../node_modules/react-dom/umd/react-
dom.development.js"></script>
<script src="../node_modules/@babel/standalone/babel.js"></script>
<script type="text/babel">
const HeaderComponent = () => {
const title = "Amazon Shopping";
const offer = "Online Shoppine - 70% OFF on Footwear";
return(
<div className="text-center text-white bg-danger mt-2 p-2">
<h2>{title}</h2>
<p>{offer}</p>
</div>
)
}
ReactDOM.render(
<HeaderComponent />,
document.getElementById("container")
)
</script>
</head>
<body class="container-fluid">
<div id="container">
</div>
</body>
</html>
</div>
</body>
</html>