jungsoft/frontend-style-guide

Remove suggested use of curried functions from style guide

Opened this issue · 1 comments

After reading through the style guide I discovered something small in the following section.

The suggested format above actually calls the function on every re-render anyways, so it's really creating more work.

I created a small JSFiddle to demonstrate this in action - as the component re-renders, the function is also re-created.

If we would like to avoid functions re-creating on each re-render we can use React useCallback, but only where it is really necessary. The following article goes more into detail about when it may be necessary to use useCallback or useMemo.

If we agree on removing this from the style guide I can submit a PR.

Good catch! That is indeed wrong.

The question now is if we should:

  1. still prefer to go for curried functions because of readability
  2. prefer to avoid curried functions because of readability
  3. leave it open and remove the section

What do you think?