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

Provide an example using JSX #203

Closed
trieloff opened this issue Sep 18, 2018 · 6 comments
Closed

Provide an example using JSX #203

trieloff opened this issue Sep 18, 2018 · 6 comments
Labels

Comments

@trieloff
Copy link
Contributor

I think we have built-in support for JSX, we just don't know it yet.

/** @jsx h */

import h from 'hyperscript';

const App = (logo) => (
  <div className="App">
    <img className="App-Logo" src={logo} alt="React Logo" />
    <h1 className="App-Title">Hello Parcel x React</h1>
  </div>
);

console.log(App("test.png").outerHTML);

(https://github.com/hyperhype/hyperscript has a React.createElement-compatible (enough) API and the /** @jsx h */ line instructs Babel to use h instead of React.createElement)

and

$ npx parcel build -t node src/*.jsx
$ node dist/html_test.js
<div class="App"><img class="App-Logo" src="test.png" alt="React Logo"><h1 class="App-Title">Hello Parcel x React</h1></div>

All that needs to be done is to create a proper main function that accepts the pipeline payload and returns the correct HTML.

@tripodsan
Copy link
Contributor

don't you think it will be too confusing for people to mix a templating language that is primarily used clientside for serverside?

@trieloff
Copy link
Contributor Author

No, there are a number of projects (e.g. next.js) that use JSX (and React) for server-side rendering.

@dplaton
Copy link

dplaton commented Mar 25, 2019

Would we use JSX to provide an alternative to HTL?

@tripodsan
Copy link
Contributor

we could, yes. but I still think we shouldn't :-)

@trieloff
Copy link
Contributor Author

In principle, Helix is agnostic to your choice of templating language and JSX has a couple of advantages over HTL:

  • it allows easy mixing of markup and code (so you often don't need a pre.js)
  • it is widely known

In order to demonstrate Helix's openness, I think it would well serve it's purpose.

trieloff added a commit that referenced this issue May 9, 2019
so far only *html.jsx is supported and no examples or tests are included

implements #203
trieloff pushed a commit that referenced this issue May 13, 2019
# [2.5.0](v2.4.1...v2.5.0) (2019-05-13)

### Features

* **build:** add basic JSX support ([aec4c8e](aec4c8e)), closes [#203](#203)
* **build:** build JSX templates/scripts by default ([2692b49](2692b49))
@adobe-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 2.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

5 participants