Hacker News new | past | comments | ask | show | jobs | submit login

Yes, it gets allocated in memory (assuming there isn't some kind of crazy runtime optimization that can figure out it won't be called and skip doing that)

One reason useCallback exists is because useMemo, too, allocates a function on every render- even if it doesn't recompute the underlying value by actually calling the function. So if you're going to be allocating a function anyway, there's no point (performance-wise) to allocating a function that creates a function. You can just cut out the middle-man




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: