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

[RAV][nextjs] Ensure component works when default personalization variant is hidden #1383

Merged
merged 4 commits into from
Mar 22, 2023

Conversation

art-alexeyenko
Copy link
Contributor

Description / Motivation

Personalized components could render an error frame when default variant is hidden. This PR fixes it.

Testing Details

  • Unit Test Added
  • Manual Test/Other - should work in normal mode, Pages, Experience Editor

Types of changes

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

@art-alexeyenko art-alexeyenko requested a review from a team March 21, 2023 20:33
Copy link
Contributor

@illiakovalenko illiakovalenko 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! See one suggestion below

@@ -211,6 +211,8 @@ export class PlaceholderCommon<T extends PlaceholderProps> extends React.Compone

if (componentRendering.componentName === HIDDEN_RENDERING_NAME) {
component = hiddenRenderingComponent ?? HiddenRendering;
} else if (!componentRendering.componentName) {
component = () => <></>;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's possible to render null value, did you try to set null?

Copy link
Contributor Author

@art-alexeyenko art-alexeyenko Mar 22, 2023

Choose a reason for hiding this comment

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

I think either one should work (null is set anyway, so another piece of code would need to be changed), but this approach is a better fit for the code flow we have now (there's a null check below that actually triggers the issue).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also it helps differentiate between an "empty" component (all good - means it's hidden) and "null" component (throws error, causes error frame to render).

@art-alexeyenko art-alexeyenko merged commit dbdf0a5 into dev Mar 22, 2023
@art-alexeyenko art-alexeyenko deleted the bug/unknown-react-component-personalize branch March 22, 2023 19:45
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