Skip to content

Instantly share code, notes, and snippets.

@vzaidman
Last active November 9, 2019 09:12
Show Gist options
  • Select an option

  • Save vzaidman/c2ee7302c9138ed6c00a52bacb7df41d to your computer and use it in GitHub Desktop.

Select an option

Save vzaidman/c2ee7302c9138ed6c00a52bacb7df41d to your computer and use it in GitHub Desktop.
React Rendered By
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)
);
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>
);
}
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