UNITIV React
UNITIV React
REACT
INTRODUCTION
• React is a JavaScript library for building user interfaces.
• React is used to build single-page applications.
• React allows us to create reusable UI components.
• React is work on components. We can create different
components and create a web page.
• Maintained by Facebook.
Why React JS
• Improves speed of app
• Uses Virtual DOM- improved performance
• Faster than DOM
• High demand due to fast speed.
• Readability –due to components
• Maintains longer code.
• Large Community for support.
• Mobile App development with react- Native.
React.JS History
function App() {
return (
<div classname="App">
<h1> hello world</h1>
</div>
);
}
function Users(){
return (
<div classname="App">
<h1> hello how are
you</h1>
</div>
);
}
It gets shorter! If the function has only one statement, and the statement returns a value, you can
remove the brackets and the return keyword:
<script>
let a = function(){
document.write("Hello
world");
}
a();
</script>
<script>
let a = () => {
document.write("hello");
=> }
a();
</script>
Promises
A JavaScript Promise object contains both the producing code and calls to the consuming code:
•Pending
•Fulfilled
•Rejected
}
});
console.log(prom);
</script>
</head>
<body>
</body>
</html>
Imperative Versus Declarative
CommonJS
CommonJS is the module pattern that’s supported by all versions of Node (see
the Node.js documentation on modules). You can still use these modules with
Babel and webpack. With CommonJS, JavaScript objects are exported using
module.exports. For example, in CommonJS, we can export the print and log
functions as an object:
const print(message) => log(message, new Date())
const log(message, timestamp) =>
console.log(`${timestamp.toString()}: ${message}`}
module.exports = {print, log}
CommonJS does not support an import statement. Instead, modules are
imported with the require function:
const { log, print } = require("./txt-helpers");
Store Multiple values in single variables.
ES6 Array Methods
ES6 Array Methods
ES6 Array Methods
ES6 Array Methods
ES6 Array Methods
ES6 Array Methods
ES6 Array map() Methods
ES6 Array Map() Method