-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
5.4 Extract Default Non-primitive Parameter Value from Memoized Component to Constant
Gives an example where memo should fail. But that's not the case – memo doesn't compare inner component arguments; it compares incoming props. Therefore, the rule and example provided are misleading and don't cause performance issues.
This will memo just fine:
const UserAvatar = memo(function UserAvatar({ onClick = () => {} }: { onClick?: () => void }) {
// ...
})
// Used without optional onClick
<UserAvatar />
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels