This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"lastUpload":"2020-09-29T11:19:23.704Z","extensionVersion":"v3.4.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| function ExampleApplication() { | |
| return ( | |
| <> | |
| <Header /> | |
| <React.StrictMode> | |
| <> | |
| <ComponentOne /> | |
| <ComponentTwo /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ErrorBoundary> | |
| <MyWidget /> | |
| </ErrorBoundary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ErrorBoundary extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { hasError: false }; | |
| } | |
| static getDerivedStateFromError(error) { | |
| // Update state so the next render will show the fallback UI. | |
| return { hasError: true }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const App = () => { | |
| const [isOn, setOn] = useState(false); | |
| return <div style={{overflow: "hidden"}}> | |
| <Button onClick={e => {setOn(!isOn)}} > | |
| Click me | |
| </Button> | |
| { | |
| isOn && | |
| <Portal> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ReactDOM.createPortal(child, container) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useEffect } from "react"; | |
| import { createPortal } from "react-dom"; | |
| const Portal = ({children}) => { | |
| const mount = document.getElementById("portal-root"); | |
| const el = document.createElement("div"); | |
| useEffect(() => { | |
| mount.appendChild(el); | |
| return () => mount.removeChild(el); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <meta name="theme-color" content="#000000" /> | |
| <meta | |
| name="description" | |
| content="Web site created using create-react-app" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { PropTypes } from 'prop-types'; | |
| const User = ({ name,age })=> { | |
| return ( | |
| <div> | |
| <p>User Name: {name}</p> | |
| <p>Age: {age}</p> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import User from './User'; | |
| class App extends React.Component { | |
| render() { | |
| return ( | |
| <div> | |
| <User name="Roei" age="30" /> | |
| </div> |
NewerOlder