Wednesday, September 9, 2020

React Practical

 I hope you all are excited!!

Now, I will begin with practical content and its work flow. First thing you all need to do is delete all the files from src folder of react app.

Now, create two file name index.js and app.js

In index.js write

import React from "react"; //import react
import ReactDom from "react-dom";// import react-dom
import App from "./App";//import the second file app from current folder
ReactDom.render(<App />document.querySelector("#root"));
/*ReactDom.render() here ReactDom is a object with render function to
render app component in div with id root. You will find that root in
index.html file in public folder*/

In app.js write

import React from "react";
/*no need to import reactdom because we already have render the
component in react dom mention in index.js file

We have used the class component but in other blog will also use
functional component

class App extending the React.Component class to get access to
React.Component function.

state handle the state of component */
class App extends React.Component {
  render() {
    return (
      <div>
        hello
      </div>
    );
  }
}
export default App;

Output:
you will find hello on browser

No comments:

Post a Comment