-
Notifications
You must be signed in to change notification settings - Fork 734
Avatar - to function (performance) #2191
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good,
I left few small comments, mostly about naming :)
src/components/avatar/index.tsx
Outdated
LogService.warn('uilib: imageSource prop is deprecated, use source instead.'); | ||
} | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider adding the imageSource
to the deps array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't expect the imageSource
to change, this is the equivalent for the usage in the constructor
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the user can pass imageSource={undefined}
until he loads the data, and then pass imageSource={someSource}
after the first mount.. we want to catch that and I don't think it's so rare
children | ||
} = themeProps; | ||
const {size: _badgeSize, borderWidth = 0} = badgeProps; | ||
const badgeSize = _badgeSize || DEFAULT_BADGE_SIZE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving the default value to the destruction (more readable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was there, this is actually a (not so readable :/) fix for a test, if the input is 0
the result should be DEFAULT_BADGE_SIZE
, let me know if you have a better suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so let's keep it that way
Description
Avatar - to function (performance)
I've added a snapshot test for the screen to verify I did not break anything, I figured we can keep it, WDYT?
I saw a significant performance improvement (15-20%) with my tests, please verify you see it too.
WOAUILIB-2913
Changelog
Avatar - to function (performance)