react.dev
react.dev copied to clipboard
Clarification on useCallback function name on beta docs
In the react beta docs, useCallback api reference page gives the following example

I think the constant naming memoizedFn leads to some confusion on what useCallback does.
People tend to assume that useCallback actually memoizes the function but it does not do that. It returns the same instance of the function between re-renders.
An appropriate name of that variable should be originalFn.
I maybe wrong so please let me know if the above makes sense.
Big fan of the beta docs btw ❤️ , beautiful documentation and excellent examples!
I agree with the concern but I don’t think your suggestion is much clearer.
how about a simple returnedFn? Since useCallback does return a function.
Maybe I can send a small PR and we can start a discussion on it. More folks can chime in.
I don't think that's better either since you could prepend any name with returned and it wouldn't change the meaning.
I agree with @gaearon; it would change the meaning