Skip to content

Instantly share code, notes, and snippets.

@hawx
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawx/6ee1b3abda6cded09435 to your computer and use it in GitHub Desktop.
Save hawx/6ee1b3abda6cded09435 to your computer and use it in GitHub Desktop.
What JSX should be
// Given we have some,
// function el(name) { return function() { ... } }
var Dropdown = el('Dropdown'),
Menu = el('Menu'),
MenuItem = el('MenuItem');
var dropdown = Dropdown(
'A dropdown list',
Menu(
MenuItem('Do Something'),
MenuItem('Do Something Fun!'),
MenuItem('Do Something Else')));
render(dropdown);
// http://facebook.github.io/jsx/#why-not-template-literals
var Box = el('Box'),
Answer = el('Answer'),
BoxComment = el('Box.Comment');
var box = Box(
shouldShowAnswer(user)
? Answer({value: false}, 'no')
: BoxComment('Text Content'))
render(box);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment