File tree Expand file tree Collapse file tree 4 files changed +16
-15
lines changed
Expand file tree Collapse file tree 4 files changed +16
-15
lines changed Original file line number Diff line number Diff line change 4848 "prettyjson" : " 1.1.3" ,
4949 "react-codemirror" : " 0.1.7" ,
5050 "react-docgen" : " 2.3.1" ,
51- "react-tools" : " 0.13.3" ,
5251 "react-transform-catch-errors" : " 1.0.0" ,
5352 "react-transform-hmr" : " 1.0.1" ,
5453 "redbox-react" : " 1.1.1" ,
Original file line number Diff line number Diff line change 11.playgroundError {
22 margin : -1rem -1rem -1.2rem ;
33 padding : 1rem ;
4+ line-height : 1.2 ;
5+ font-size : .9rem ;
46 color : # fff ;
57 background : # c00 ;
68}
Original file line number Diff line number Diff line change 22
33import React , { Component , PropTypes } from 'react' ;
44import ReactDOM from 'react-dom' ;
5- import reactTools from 'react-tools ' ;
5+ import babel from 'babel-core/browser ' ;
66import Wrapper from 'components/Wrapper' ;
77
88import s from './Preview.css' ;
@@ -29,29 +29,26 @@ export default class Preview extends Component {
2929 }
3030 }
3131
32- compileCode ( ) {
33- // TODO: Babel
34- return reactTools . transform ( this . props . code , {
35- harmony : true
36- } ) ;
32+ compileCode ( code ) {
33+ return babel . transform ( code , { stage : 0 } ) . code ;
3734 }
3835
3936 executeCode ( ) {
4037 let mountNode = this . refs . mount ;
4138
42- try {
43- ReactDOM . unmountComponentAtNode ( mountNode ) ;
44- }
45- finally {
46- /* */
47- }
39+ ReactDOM . unmountComponentAtNode ( mountNode ) ;
4840
4941 this . setState ( {
5042 error : null
5143 } ) ;
5244
45+ let { code } = this . props ;
46+ if ( ! code ) {
47+ return ;
48+ }
49+
5350 try {
54- let compiledCode = this . compileCode ( ) ;
51+ let compiledCode = this . compileCode ( code ) ;
5552 let component = eval ( compiledCode ) ; /* eslint no-eval:0 */
5653 let wrappedComponent = (
5754 < Wrapper >
@@ -72,7 +69,7 @@ export default class Preview extends Component {
7269 let { error } = this . state ;
7370 if ( error ) {
7471 return (
75- < div className = { s . playgroundError } > { error } </ div >
72+ < pre className = { s . playgroundError } > { error } </ pre >
7673 ) ;
7774 }
7875 else {
Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ module.exports = function(env) {
6464 ] ,
6565 module : {
6666 loaders : [
67+ ] ,
68+ noParse : [
69+ / b a b e l - c o r e \/ b r o w s e r .j s /
6770 ]
6871 } ,
6972 postcss : function ( ) {
You can’t perform that action at this time.
0 commit comments