Skip to content

Commit

Permalink
feat: way1 to create react application
Browse files Browse the repository at this point in the history
  • Loading branch information
ap221882 committed Jan 22, 2023
1 parent c6979ce commit 5cef309
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Revision/Basic_React/way1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- ?React Scripts -->
<script
src="https://unpkg.com/react@18/umd/react.production.min.js"
crossorigin
defer
></script>
<script
src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
crossorigin
defer
></script>
<!-- ?Local Script -->
<script src="script.js" type="module"></script>
<title>Smallest React Application</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
34 changes: 34 additions & 0 deletions Revision/Basic_React/way1/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
console.log(React, 'React');
console.log(ReactDOM, 'ReactDOM');

const element = React.createElement(
'h1',
{ ajay: 'pathak' },
'I am learning react'
);

const rootDOMElement = document.querySelector('#root');
console.log(rootDOMElement, 'rootDOMElement');

const rootInstance = ReactDOM.createRoot(rootDOMElement);

//~! Mount
rootInstance.render(element);

ReactDOM.flushSync(() => {
rootInstance.render(element);
});

console.log(rootDOMElement.innerHTML);

//~! SERVER CODE
// const treeString = ReactDOM.renderToString(element);
// console.log(treeString, 'treeString');

//~! Unmount
// rootInstance.unmount();

console.log(rootInstance, 'rootInstance');
console.dir(rootInstance.unmount, 'rootInstance.unmount');

ReactDOM.unmountComponentAtNode(rootDOMElement);
13 changes: 13 additions & 0 deletions Revision/Basic_React/way2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="script.js" type="module"></script>
<title>Smallest React Application</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

2 comments on commit 5cef309

@vercel
Copy link

@vercel vercel bot commented on 5cef309 Jan 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

namaste-react – ./Day12/github-api-project-ts

namaste-react-git-main-ap221882.vercel.app
namaste-react-ap221882.vercel.app
namaste-react.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 5cef309 Jan 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

namaste-react-parcel – ./Day3

namaste-react-parcel.vercel.app
namaste-react-parcel-git-main-ap221882.vercel.app
namaste-react-parcel-ap221882.vercel.app

Please sign in to comment.