Skip to content
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

Improving rendering of TimeRangeDropdown component. #13554

Merged
merged 2 commits into from
Sep 29, 2022

Conversation

dennisoelkers
Copy link
Member

Description

Motivation and Context

In the last weeks, the test for the TimeRangeDropdown component was running into timeouts repeatedly. In order to address this, the component itself was improved by usages of useMemo/useCallback in order to prevent unnecessary rerenders. On my local machine the test runtime was reduced from 1.2s to 600ms. In addition, a couple of typing issues were addressed.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@dennisoelkers dennisoelkers force-pushed the refactor/improve-time-range-dropdown-runtime branch from 1e56b6e to 7f9adaf Compare September 27, 2022 13:37
@@ -224,6 +255,9 @@ const TimeRangeDropdown = ({
</PopoverTitle>
);

const _validateTimeRange = useCallback(({ nextTimeRange }) => dateTimeValidate(nextTimeRange, limitDuration, formatTime), [formatTime, limitDuration]);
const initialTimeRange = { nextTimeRange: onInitializingNextTimeRange(currentTimeRange) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use useMemo here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure! I could swear I did that :)

@dennisoelkers dennisoelkers force-pushed the refactor/improve-time-range-dropdown-runtime branch from 1025e31 to f875c10 Compare September 29, 2022 10:36
Copy link
Contributor

@linuspahl linuspahl 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 to me, works as expected!

@dennisoelkers dennisoelkers merged commit 670e687 into master Sep 29, 2022
@dennisoelkers dennisoelkers deleted the refactor/improve-time-range-dropdown-runtime branch September 29, 2022 12:49
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