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

feat: Support nested children in JSX #2482

Merged
merged 4 commits into from
Jun 12, 2024

Conversation

FrederikBolding
Copy link
Member

Support nested children in JSX, allowing for UIs to be created like:

<Box>
  <Text>Hello</Text>
  {[1, 2, 3].map((value) => (
    <Text>{value.toString()}</Text>
  ))}
  <Text>World</Text>
</Box>

We flatten the children array in getJsxChildren, which should be used in the client implementation to handle this additional complexity.

@FrederikBolding FrederikBolding requested a review from a team as a code owner June 12, 2024 10:53
@@ -48,7 +50,7 @@ export type SnapElement<
* const maybeArrayString: MaybeArrayString = 'hello';
* const maybeArrayStringArray: MaybeArrayString = ['hello', 'world'];
*/
export type MaybeArray<Type> = Type | Type[];
export type MaybeArray<Type> = Type | Type[] | Nestable<Type>;
Copy link
Member

Choose a reason for hiding this comment

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

This is redundant.

Suggested change
export type MaybeArray<Type> = Type | Type[] | Nestable<Type>;
export type MaybeArray<Type> = Nestable<Type>;

packages/snaps-sdk/src/jsx/component.ts Show resolved Hide resolved
Copy link

codecov bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.34%. Comparing base (504e4fd) to head (25318a8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2482   +/-   ##
=======================================
  Coverage   94.34%   94.34%           
=======================================
  Files         439      439           
  Lines        9053     9057    +4     
  Branches     1392     1392           
=======================================
+ Hits         8541     8545    +4     
  Misses        512      512           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@FrederikBolding FrederikBolding merged commit e70760f into main Jun 12, 2024
153 checks passed
@FrederikBolding FrederikBolding deleted the fb/support-nested-children-in-jsx branch June 12, 2024 12:02
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