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

Fix loop in Propositions SPA sandbox page #1010

Merged
merged 2 commits into from
Jul 11, 2023
Merged

Conversation

carterworks
Copy link
Contributor

Description

Deep compare data and xdm in the useSendPageViewEvent() hook. If data and xdm are not passed in, a new object is created which doesn't pass the === test, causing the function to run again even though there are no real changes. Instead, we deeply compare them between runs. The performance hit should be minimal because they are small objects.

Related Issue

Fixes #1005

Motivation and Context

Screenshots (if appropriate):

Types of changes

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

Checklist:

  • I have signed the Adobe Open Source CLA or I'm an Adobe employee.
  • I have made any necessary test changes and all tests pass.
  • I have run the Sandbox successfully.

Every time the useSendPageViewEvent() function was being called without
the xdm and data params being specified, the default parameter would
create a new object. This would make the function run again aka it was
not safe to call multiple times because the data and xdm variables
didn't pass the === test.
Since the values are small, there isn't much worry about performance.
See this comment about the subject: facebook/react#14476 (comment)
@carterworks carterworks self-assigned this Jul 11, 2023
@carterworks carterworks added the ignore-for-release Do not include this PR in release notes label Jul 11, 2023
@carterworks carterworks merged commit 92fd609 into main Jul 11, 2023
@carterworks carterworks deleted the fix-propositions-spa-loop branch July 11, 2023 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-for-release Do not include this PR in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sandbox SPA example stuck in loop
1 participant