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

Add support for JSX Fragments #1589

Open
tbuschto opened this issue Feb 14, 2018 · 1 comment
Open

Add support for JSX Fragments #1589

tbuschto opened this issue Feb 14, 2018 · 1 comment

Comments

@tbuschto
Copy link
Member

tbuschto commented Feb 14, 2018

Currently the shortest syntax is to add multiple JSX elements in one append call is to use commas:

ui.contentView.append(
  <button centerX={0} top={100} text='Show Message'/>,
  <textView centerX={0} top='prev() 50' font='24px'/>
);

Very ugly. The alternative is to use WidgetCollection:

ui.contentView.append(
  <widgetCollection>
    <button centerX={0} top={100} text='Show Message'/>
    <textView centerX={0} top='prev() 50' font='24px'/>
  </widgetCollection>
);

However, this is much longer. In React there is also the fragment element, which would make it look like this:

ui.contentView.append(
  <>
    <button centerX={0} top={100} text='Show Message'/>
    <textView centerX={0} top='prev() 50' font='24px'/>
  </>
);

TypeScript added support for this syntax in 2.7, but it does not work in Tabris.js because we use the jsxFactory compiler option. This is a limitation that may be eliminated in the near future: microsoft/TypeScript#20469

Once fragments work with jsxFactory we should support it.

@tbuschto
Copy link
Member Author

Compromise: #1679

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant