Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a callback in useMemo receive any arguments?

I wonder if useMemo hook receives previous value for whatever it has memoized as any of the arguments to its callback?

like image 857
jayarjo Avatar asked Mar 05 '23 06:03

jayarjo


1 Answers

Does a callback in useMemo receive any arguments?

No, The callback to useMemo doesn't receive any arguments. It just relies on the array passed as second argument to execute the callback and return any result returned after executing the callback.

You can find a demonstration of this in codesandbox here

like image 131
Shubham Khatri Avatar answered Mar 08 '23 23:03

Shubham Khatri