Skip to content

Commit e63b05b

Browse files
committed
Remove codesplitting
1 parent e252aae commit e63b05b

File tree

1 file changed

+16
-37
lines changed

1 file changed

+16
-37
lines changed

examples/src/components/ExampleItem.js

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
import React, { Component } from 'react';
22
import T from 'prop-types';
33
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; // eslint-disable-line
4+
import { LiveProvider, LiveEditor, LivePreview, LiveError } from 'react-live';
45
import classNames from 'classnames';
56

6-
let ReactLive;
7-
87
const scope = { Tabs, Tab, TabList, TabPanel };
98

109
export default class ExampleItem extends Component {
1110
state = {
1211
editorOpen: false,
13-
liveLoaded: false,
1412
};
1513

16-
constructor(props) {
17-
super(props);
18-
19-
import('react-live').then(Live => {
20-
ReactLive = Live;
21-
this.setState({ liveLoaded: true });
22-
});
23-
}
24-
2514
toggleCheckbox({ target: { name, checked } }) {
2615
this.setState({
2716
[name]: checked,
@@ -40,34 +29,11 @@ export default class ExampleItem extends Component {
4029
return <div className="hint">{this.props.hint}</div>;
4130
}
4231

43-
renderLiveEditor() {
44-
if (!this.state.liveLoaded) return null;
45-
32+
render() {
4633
const { editorOpen } = this.state;
4734
const editorClassNames = classNames('live-editor', {
4835
'live-editor--visible': editorOpen,
4936
});
50-
51-
return (
52-
<ReactLive.LiveProvider
53-
mountStylesheet={false}
54-
scope={scope}
55-
code={this.props.code}
56-
noInline
57-
>
58-
<ReactLive.LiveError />
59-
<div className="live-preview">
60-
<div className={editorClassNames}>
61-
<ReactLive.LiveEditor ignoreTabKey />
62-
</div>
63-
<ReactLive.LivePreview />
64-
</div>
65-
</ReactLive.LiveProvider>
66-
);
67-
}
68-
69-
render() {
70-
const { editorOpen } = this.state;
7137
const formId = `editorOpen${this.props.label.replace(' ', '_')}`;
7238

7339
return (
@@ -86,7 +52,20 @@ export default class ExampleItem extends Component {
8652
</label>
8753
</h3>
8854
{this.renderHint()}
89-
{this.renderLiveEditor()}
55+
<LiveProvider
56+
mountStylesheet={false}
57+
scope={scope}
58+
code={this.props.code}
59+
noInline
60+
>
61+
<LiveError />
62+
<div className="live-preview">
63+
<div className={editorClassNames}>
64+
<LiveEditor ignoreTabKey />
65+
</div>
66+
<LivePreview />
67+
</div>
68+
</LiveProvider>
9069
</div>
9170
);
9271
}

0 commit comments

Comments
 (0)