Skip to content

Commit 15da726

Browse files
committed
Remove unnecessary React.cloneElement (fix styleguidist#159).
1 parent 3b110f4 commit 15da726

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/rsg-components/Preview/Preview.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ export default class Preview extends Component {
8585

8686
const exampleComponent = this.props.evalInContext(exampleComponentCode);
8787

88-
// Wrap everything in a react component, such that we can leverage the state management of this component
88+
// Wrap everything in a react component to leverage the state management of this component
8989
class PreviewComponent extends Component { // eslint-disable-line react/no-multi-comp
90-
constructor(props) {
91-
super(props);
90+
constructor() {
91+
super();
9292

9393
const state = {};
9494
const initialStateCB = (initialState) => {
@@ -108,11 +108,7 @@ export default class Preview extends Component {
108108
return <pre className={s.playgroundError}>{this.state.error}</pre>;
109109
}
110110

111-
const setState = (nextState, callback) => this.setState(nextState, callback);
112-
const state = this.state;
113-
114-
// Pass through props from the wrapper component
115-
return React.cloneElement(exampleComponent(state, setState, null), this.props);
111+
return exampleComponent(this.state, this.setState.bind(this), null);
116112
}
117113
}
118114

0 commit comments

Comments
 (0)