Last active
November 9, 2019 09:12
-
-
Save vzaidman/c2ee7302c9138ed6c00a52bacb7df41d to your computer and use it in GitHub Desktop.
React Rendered By
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
| function App() { | |
| console.log("App - start render"); | |
| React.useEffect(() => console.log("App - rendered")); | |
| return ( | |
| <Parent> | |
| <Child /> | |
| <Child /> | |
| <Child /> | |
| </Parent> | |
| ); | |
| } | |
| React.createElement( | |
| Parent, | |
| null, | |
| React.createElement(Child, null), | |
| React.createElement(Child, null), | |
| React.createElement(Child, null) | |
| ); |
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
| function Parent({ children }) { | |
| console.log("Parent - start render"); | |
| React.useEffect(() => console.log("Parent - rendered")); | |
| const [count, setCount] = React.useState(0); | |
| return ( | |
| <div className="parent"> | |
| <button onClick={() => setCount(count + 1)}>increase {count}</button> | |
| {children} | |
| </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
| function Child() { | |
| console.log("Child - start render"); | |
| React.useEffect(() => console.log("Child - rendered")); | |
| return <div className="child">child</div>; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment