Skip to content

Add hJSX() helper to ease JSX usage in Babel

Choose a tag to compare

@staltz staltz released this 18 Jul 14:06
· 413 commits to master since this release

Now it is (a bit) easier to use JSX with Cycle.js

If you are using Babel, then add the following line at the top of the file which will use JSX:

/** @jsx hJSX */

Then import hJSX:

import {hJSX} from '@cycle/web';

And now JSX will render VTrees:

return (
  <ul>
    <li><a className="link" href="/">Home</a></li>
    <li><a className="link" href="/about">About</a></li>
  </ul>
);

equivalent to

return h('ul', [
  h('li', [
    h('a.link', {href: '/'}, 'Home')
  ]),
  h('li', [
    h('a.link', {href: '/about'}, 'About')
  ])
]);