Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove suggested use of curried functions from style guide #6

Open
dylan1p opened this issue Jun 30, 2021 · 1 comment
Open

Remove suggested use of curried functions from style guide #6

dylan1p opened this issue Jun 30, 2021 · 1 comment

Comments

@dylan1p
Copy link

dylan1p commented Jun 30, 2021

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.

@gabrielpra1
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants