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

Avoid excessive reexecution of useSendTelemetry. #19896

Merged
merged 12 commits into from
Jul 16, 2024

Conversation

dennisoelkers
Copy link
Member

Description

Motivation and Context

This PR is optimizing useSendTelemetry for minimal reexecutions. Previously, the hook was reexecuting on every route change, due to useLocation in useRoutePattern triggering a rerender. In many cases this was unnecessary, as the returned location would on be used when the telemetry function that is produced is actually executed.

Therefore, this change is now pushing the route parsing into the generated function, so it does not need to be regenerated when the route changes. As the hook is consumed in many places and its reexecution and constant regeneration of the function it produces, this change is avoiding cascading rerenders.

/nocl No user-facing change.

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 fix/improve-use-send-telemetry-perf branch from 75f4b2b to bc51841 Compare July 15, 2024 11:30
Copy link
Contributor

@ousmaneo ousmaneo left a comment

Choose a reason for hiding this comment

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

LGTM!

@dennisoelkers dennisoelkers merged commit 2d20aea into master Jul 16, 2024
6 checks passed
@dennisoelkers dennisoelkers deleted the fix/improve-use-send-telemetry-perf branch July 16, 2024 08:01
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