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 SEO > LDJson Hydration warning #390

Merged
merged 1 commit into from
Jan 25, 2023
Merged

Conversation

cartogram
Copy link
Contributor

When I moved this library to use React.createElement from plain jsx tags, I failed to remember that the script tag data needs to be passed in "dangerously" 💀 ... without this, the data is serialized and causes a mis-match on server/client.

Thanks @wizardlyhel for pointing this out.

Before

Screenshot 2023-01-25 at 18 45 33

After

Screenshot 2023-01-25 at 18 43 58

@cartogram cartogram requested a review from a team January 25, 2023 17:46
@github-actions
Copy link
Contributor

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset.
If the changes are user-facing and should cause a version bump, run npm run changeset add to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to examples or documentation, you do not need to add a changeset.

return React.createElement(tag.tag, {
...tag.props,
key: tag.key,
dangerouslySetInnerHTML: {__html: tag.children},
Copy link
Contributor

Choose a reason for hiding this comment

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

Could it also be JSON.stringify() instead? Just wondering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is already by stringified because it comes from the generateSeoTags as a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could move that stringification here (put in on the user). Perhaps something to revisit when we see more usage.

Copy link
Contributor

Choose a reason for hiding this comment

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

could be possible? set on text with JSON.stringify and we won't get appsec warning us about using dangerouslySetInnerHTML

@cartogram cartogram merged commit 150340b into v0.x-2022-10 Jan 25, 2023
@cartogram cartogram deleted the fix-ldjson-hydration branch January 25, 2023 17:55
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.

3 participants