File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change 1- import { memo , useCallback , useMemo , useState } from 'react' ;
1+ import { memo , useCallback , useState } from 'react' ;
22
33const App = ( ) => {
44 console . log ( 'renders <App />' ) ;
@@ -63,23 +63,21 @@ const AddButton = ({ disabled, onClick }) => {
6363 ) ;
6464} ;
6565
66- const Total = memo ( ( { cartItems } ) => {
66+ const Total = ( { cartItems } ) => {
6767 console . log ( 'renders <Total />' ) ;
6868
69- const total = useMemo ( ( ) => {
70- return cartItems . reduce ( ( acc , cur ) => {
71- const t = Date . now ( ) ;
69+ const total = cartItems . reduce ( ( acc , cur ) => {
70+ const t = Date . now ( ) ;
7271
73- while ( Date . now ( ) - t < 100 ) {
74- // 擬似的に100ミリ秒の遅延を発生させる
75- }
72+ while ( Date . now ( ) - t < 100 ) {
73+ // 擬似的に100ミリ秒の遅延を発生させる
74+ }
7675
77- return cur . length * 100 + acc ;
78- } , 0 ) ;
79- } , [ cartItems ] ) ;
76+ return cur . length * 100 + acc ;
77+ } , 0 ) ;
8078
8179 return < p > 合計: { total } 円</ p > ;
82- } ) ;
80+ } ;
8381
8482const ClearButton = memo ( ( { onClick } ) => {
8583 console . log ( 'renders <ClearButton />' ) ;
You can’t perform that action at this time.
0 commit comments