Skip to content

Commit 04dcc59

Browse files
committed
Total コンポーネントを memo でメモ化
1 parent 82b04e2 commit 04dcc59

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useMemo, useState } from 'react';
1+
import { memo, useMemo, useState } from 'react';
22

33
const App = () => {
44
console.log('renders <App />');
@@ -58,7 +58,7 @@ const AddButton = ({ disabled, onClick }) => {
5858
);
5959
};
6060

61-
const Total = ({ cartItems }) => {
61+
const Total = memo(({ cartItems }) => {
6262
console.log('renders <Total />');
6363

6464
const total = useMemo(() => {
@@ -74,6 +74,6 @@ const Total = ({ cartItems }) => {
7474
}, [cartItems]);
7575

7676
return <p>合計: {total}</p>;
77-
};
77+
});
7878

7979
export default App;

0 commit comments

Comments
 (0)