Manual memoization → Auto memoization
Example)
import { useState } from "react";
export default function MyApp() {
const [name, setName] = useState("");
const [address, setAddress] = useState("");
const handleSubmit = (orderDetails) => {
setAddress("122-2222");
post("/product/" + productId + "/buy", {
referrer,
orderDetails,
});
};
j;
const visibleTodos = () => filterTodos(todos, tab);
return (
<>
{address}
Click!!
Click!!
);
}
function Greeting({ name }) {
console.log("Greeting was rendered at", new Date().toLocaleTimeString());
return (
Hello{name && ", "}
{name}!
);
} 15