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: Missing error on invalid island children #1736

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

marvinhagemeister
Copy link
Collaborator

In #1674 a reproduction was posted where a json object was passed to an island instead of an expected JSX element.

<Island>{{ foo: 123 }}</Island>

Whilst this is technically possible in Preact, if the receiving component knows how to deal with that, it's not something that's encouraged. It breaks the compositional nature of components and leads to difficult to understand errors.

Instead users should pass data via any other prop where the already existing serialization mechanism we have in Fresh will kick in. The children prop is reserved for JSX nodes only.

All this PR does, is throw an error when it detects that the user is trying to pass something invalid via children to an island

@marvinhagemeister marvinhagemeister changed the title fix: no error thrown on invalid island children fix: Missing error on invalid island children Sep 5, 2023
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM!

@marvinhagemeister marvinhagemeister merged commit 7004eae into main Sep 5, 2023
5 checks passed
@marvinhagemeister marvinhagemeister deleted the invalid-island-children branch September 5, 2023 13:15
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