Skip to content

Commit

Permalink
🔖 Portals
Browse files Browse the repository at this point in the history
Portals
  • Loading branch information
SaishJ committed Sep 11, 2022
1 parent 5f23da7 commit 89a9384
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,5 @@ export default ClassClick;
### [Refs](https://github.com/SaishJ/React-JS-Beginner-to-Advanced/commit/e0b4e20d4af20eea937a3258fd52c0793f5f95d0)

### [Refs with Class Component](https://github.com/SaishJ/React-JS-Beginner-to-Advanced/commit/6eb606c14741e6397a9a91a0cf0d5cfb20e1163c)

### [Forwarding Refs](https://github.com/SaishJ/React-JS-Beginner-to-Advanced/commit/9a57ffbe3d6eeea400c3604bc66fe6bb6bafabdd)
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<div id="portal"></div>
</body>
</html>
4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import RefsDemo from "./components/RefsDemo1";
import RefDemo2 from "./components/RefDemo2";
import FocusInput from "./components/FocusInput";
import FRParentInput from "./components/FRParentInput";
import PortalDemo from "./components/PortalDemo";

function App() {
return (
<div className="App">
<FRParentInput />
<PortalDemo />
{/* <FRParentInput /> */}
{/* <FocusInput /> */}
{/* <RefsDemo /> */}
{/* <RefDemo2 /> */}
Expand Down
16 changes: 16 additions & 0 deletions src/components/PortalDemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import ReactDOM from "react-dom";

function PortalDemo() {
return ReactDOM.createPortal(
<h1>Portal Demo</h1>,
document.getElementById("portal")
);
}

export default PortalDemo;

/*
Portal:- It is a way to render children into a DOM node that occurs outside the DOM hierarchy
of the parent component.
*/

0 comments on commit 89a9384

Please sign in to comment.