You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: