Last active
August 29, 2015 14:06
-
-
Save hawx/6ee1b3abda6cded09435 to your computer and use it in GitHub Desktop.
What JSX should be
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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