const WithoutUseMemo = () => {
const name = useInput();
const [reviews, setReviews] = useState(reviewData);
// expensive calculation
const average = reviews.reduce((acc, review) => acc + review.rating, 0) / reviews.length,
console.log(average);
return (
<>
<Average average={average} />
<Input {...name} placeholder="Enter your name" />
</>
);
};
export default WithoutUseMemo;
Note: Code snippets do not include styling details unless they are the focus of the exercise.
Copyright © 2022 Explore React