Deeper Dive Into ReactDDIR

React quiz - re-render with elements from prop

moving elements to parent could help prevent unnecessary renders.

re-render with elements from prop (pass rate: 51%)react@18.3.1
{...}
import * as React from "react";
import { useState, useEffect, memo } from "react";
import { createRoot } from "react-dom/client";
function A({ children }) {
console.log("A");
return children;
}
const B = memo(() => {
console.log("B");
return <C />;
});
function C() {
console.log("C");
return null;
}
function D() {
console.log("D");
return null;
}
function App() {
const [state, setState] = useState(0);
useEffect(() => {
setState((state) => state + 1);
}, []);
console.log("App");
return (
<div>
<A>
<B />
</A>
<D />
</div>
);
}
const root = createRoot(document.getElementById("root"));
root.render(<App />);
{...}
import * as React from "react";
import { useState, useEffect, memo } from "react";
import { createRoot } from "react-dom/client";
function A({ children }) {
console.log("A");
return children;
}
const B = memo(() => {
console.log("B");
return <C />;
});
function C() {
console.log("C");
return null;
}
function D() {
console.log("D");
return null;
}
function App() {
const [state, setState] = useState(0);
useEffect(() => {
setState((state) => state + 1);
}, []);
console.log("App");
return (
<div>
<A>
<B />
</A>
<D />
</div>
);
}
const root = createRoot(document.getElementById("root"));
root.render(<App />);
What gets logged in order?

click on the console.log lines to input your answer.