@@ -13,15 +13,38 @@ var HelloMessage = React.createClass({\n\
1313React.renderComponent(<HelloMessage name=\"John\" />, mountNode);\
1414" ;
1515
16- var transformer = function ( code ) {
17- return JSXTransformer . transform ( code ) . code ;
16+ function transformer ( harmony , code ) {
17+ return JSXTransformer . transform ( code , { harmony : harmony } ) . code ;
1818}
19+
20+ var CompilerPlayground = React . createClass ( {
21+ getInitialState : function ( ) {
22+ return { harmony : false } ;
23+ } ,
24+ handleHarmonyChange : function ( e ) {
25+ this . setState ( { harmony : e . target . checked } ) ;
26+ } ,
27+ render : function ( ) {
28+ return (
29+ < div >
30+ < ReactPlayground
31+ codeText = { HELLO_COMPONENT }
32+ renderCode = { true }
33+ transformer = { transformer . bind ( null , this . state . harmony ) }
34+ showCompiledJSTab = { false }
35+ />
36+ < label className = "compiler-option" >
37+ < input
38+ type = "checkbox"
39+ onChange = { this . handleHarmonyChange }
40+ checked = { this . state . harmony } /> { ' ' }
41+ Enable ES6 transforms (< code > --harmony</ code > )
42+ </ label >
43+ </ div >
44+ ) ;
45+ } ,
46+ } ) ;
1947React . renderComponent (
20- < ReactPlayground
21- codeText = { HELLO_COMPONENT }
22- renderCode = { true }
23- transformer = { transformer }
24- showCompiledJSTab = { false }
25- /> ,
48+ < CompilerPlayground /> ,
2649 document . getElementById ( 'jsxCompiler' )
2750) ;
0 commit comments