Skip to content

Commit d3fc5ad

Browse files
sophiebitsvjeux
authored andcommitted
Properly clear live editor on JSX compile failure
1 parent 761e1c8 commit d3fc5ad

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

docs/_js/live_editor.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,9 @@ var ReactPlayground = React.createClass({
115115
compiledCode = this.compileCode();
116116
} catch (err) {}
117117

118-
// we're creating both versions, to avoid the flicker when switching from
119-
// one view to another when CodeMirror recompiles
120118
var jsContent =
121119
<CodeMirrorEditor
122-
style={{display: isJS ? 'inherit' : 'none'}}
120+
key="js"
123121
className="playgroundStage CodeMirror-readonly"
124122
onChange={this.handleCodeChange}
125123
codeText={compiledCode}
@@ -128,7 +126,7 @@ var ReactPlayground = React.createClass({
128126

129127
var jsxContent =
130128
<CodeMirrorEditor
131-
style={{display: isJS ? 'none' : 'inherit'}}
129+
key="jsx"
132130
onChange={this.handleCodeChange}
133131
className="playgroundStage"
134132
codeText={this.state.code}
@@ -154,8 +152,7 @@ var ReactPlayground = React.createClass({
154152
</div>
155153
</div>
156154
<div className="playgroundCode">
157-
{jsxContent}
158-
{jsContent}
155+
{isJS ? jsContent : jsxContent}
159156
</div>
160157
<div className="playgroundPreview">
161158
<div ref="mount" />

0 commit comments

Comments
 (0)