Skip to content

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

Merged
merged 6 commits into from
Aug 16, 2022
Merged

Conversation

M-i-k-e-l
Copy link
Collaborator

@M-i-k-e-l M-i-k-e-l commented Aug 14, 2022

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)

Copy link
Contributor

@lidord-wix lidord-wix left a 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 :)

LogService.warn('uilib: imageSource prop is deprecated, use source instead.');
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Copy link
Contributor

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

Copy link
Collaborator Author

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.

Copy link
Contributor

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;
Copy link
Contributor

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)

Copy link
Collaborator Author

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.

Copy link
Contributor

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

@M-i-k-e-l M-i-k-e-l requested a review from lidord-wix August 15, 2022 15:55
@lidord-wix lidord-wix merged commit 726f8b4 into master Aug 16, 2022
@M-i-k-e-l M-i-k-e-l deleted the perf/avatar-to-function branch August 16, 2022 08:59
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

Successfully merging this pull request may close these issues.

2 participants