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
This function doesn't rely on any variables in its enclosing scope, so could be defined outside the component, which makes rendering more performant. Not a big deal for a small app, but good to know going forward.
If you did have a function that referenced variables in the enclosing scope (e.g. index), you can either make the function accept additional parameters or use useCallback which memoises functions defined within the component.
The text was updated successfully, but these errors were encountered:
I would definitely advise using caution to avoid prematurely optimising for things like this though. E.g. useCallback/other types of memoization aren't free. Creating a tiny function every render is super fast in browsers nowadays, so I would only bother to do this if you had actually noticed a performance problem.
ReactWeek-Martha-Georgia/src/components/QuizQuesAns.js
Lines 23 to 25 in b9507cf
This function doesn't rely on any variables in its enclosing scope, so could be defined outside the component, which makes rendering more performant. Not a big deal for a small app, but good to know going forward.
If you did have a function that referenced variables in the enclosing scope (e.g.
index
), you can either make the function accept additional parameters or useuseCallback
which memoises functions defined within the component.The text was updated successfully, but these errors were encountered: