Closures in React
Closures are a fundamental concept in JavaScript.
It’s a concept that is often asked about in technical interviews, and I remember memorizing it while preparing for my own technical interviews.
However, I didn’t quite understand how closures are used in practice, and I often pondered how to apply them effectively. This time, I want to study the concept of closures in more depth.
Problem
When passing a function as a parameter to customHook
, let’s observe how the state
value inside the function is output when the useCustom
component is unmounted.